diff --git a/README.md b/README.md index e19c4ac..1d96b32 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,12 @@ const { isInPipMode } = ExpoPip.useIsInPip(); ExpoPip.setAutoEnterEnabled(true); ``` +### Set desired aspect ratio + +```js +ExpoPip.setAspectRatio({ width: 200, height: 300 }); +``` + ### Enter Picture In Picture mode with desired size ```js diff --git a/android/src/main/java/expo/modules/pip/ExpoPipModule.kt b/android/src/main/java/expo/modules/pip/ExpoPipModule.kt index e03c591..2ccb12f 100644 --- a/android/src/main/java/expo/modules/pip/ExpoPipModule.kt +++ b/android/src/main/java/expo/modules/pip/ExpoPipModule.kt @@ -27,6 +27,14 @@ class ExpoPipModule : Module() { } } + Function("setAspectRatio"){ width:Int, height:Int -> + val pictureInPictureParamsBuilder = PictureInPictureParams.Builder() + val ratio = Rational(width, height) + pictureInPictureParamsBuilder.setAspectRatio(ratio) + appContext.currentActivity?.setPictureInPictureParams(pictureInPictureParamsBuilder.build()) + + } + Function("enterPipMode") { width:Int?, height:Int? -> if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ val ratWidth = width ?: 200 @@ -36,10 +44,10 @@ class ExpoPipModule : Module() { val pictureInPictureParamsBuilder = PictureInPictureParams.Builder() - pictureInPictureParamsBuilder.setAspectRatio(ratio).build() + pictureInPictureParamsBuilder.setAspectRatio(ratio) appContext.currentActivity?.enterPictureInPictureMode(pictureInPictureParamsBuilder.build()) } } } -} +} \ No newline at end of file diff --git a/example/App.tsx b/example/App.tsx index cc3a024..c169fee 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -14,7 +14,7 @@ export default function App() {