override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode)
if (lifecycle.currentState == Lifecycle.State.CREATED) {
// when user clicks on Close button of PIP
finishAndRemoveTask()
} else {
StreamVideoReactNative.onPictureInPictureModeChanged(isInPictureInPictureMode)
StreamVideoReactNative.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
}
}
1.9.0
Picture-in-picture (PiP) mode for Android has been revamped!
🔨 What changed?
Android 12+ now uses setAutoEnterEnabled
api instead of being dependent on onUserHint
, this has the added benefit of providing much smoother transitions in the newer android platforms.
💡 How to migrate?
Please visit our PiP setup documentation for Android and go through the steps again.
🚨 Breaking Changes
- The
onPictureInPictureModeChanged
method in the SDK now needs a new parameter for passing screen configuration.
- The
onUserLeaveHint
method to be added in your app is now much simpler.
public override fun onUserLeaveHint() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && StreamVideoReactNative.canAutoEnterPictureInPictureMode) {
val builder = PictureInPictureParams.Builder()
builder.setAspectRatio(Rational(480, 640))
enterPictureInPictureMode(builder.build())
override fun onUserLeaveHint() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Build.VERSION.SDK_INT < Build.VERSION_CODES.S && StreamVideoReactNative.canAutoEnterPictureInPictureMode) {
val config = resources.configuration
onPictureInPictureModeChanged(true, config)
}
}
- The expo config plugin for adding Android PiP has been changed.
androidPictureInPicture: {
enableAutomaticEnter: true,
},
androidPictureInPicture: true,
On this page: