diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9e17ac89..0297135c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -36,6 +36,7 @@ android:name=".player.PlayerActivity" android:launchMode="singleTop" android:screenOrientation="sensorLandscape" + android:supportsPictureInPicture="true" android:theme="@style/AppTheme.Player" /> = Build.VERSION_CODES.O && isInPictureInPictureMode) { + playerView.useController = false + } + // Handle current orientation and update fullscreen state restoreFullscreenState() setupFullscreenSwitcher() @@ -248,6 +251,16 @@ class PlayerActivity : AppCompatActivity() { return viewModel.mediaSourceManager.selectSubtitle(index) } + override fun onUserLeaveHint() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && viewModel.playerOrNull?.isPlaying == true) { + enterPictureInPictureMode(PictureInPictureParams.Builder().build()) + } + } + + override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) { + playerView.useController = !isInPictureInPictureMode + } + override fun onStop() { super.onStop() orientationListener.disable()