fixed pip exit

This commit is contained in:
LagradOst 2022-04-10 00:05:42 +02:00
parent aae4ed555b
commit 641025fa2d
2 changed files with 11 additions and 2 deletions

View file

@ -92,6 +92,10 @@ abstract class AbstractPlayerFragment(
throw NotImplementedError()
}
open fun exitedPipMode() {
throw NotImplementedError()
}
private fun keepScreenOn(on: Boolean) {
if (on) {
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@ -160,7 +164,7 @@ abstract class AbstractPlayerFragment(
isInPIPMode = isInPictureInPictureMode
if (isInPictureInPictureMode) {
// Hide the full-screen UI (controls, etc.) while in picture-in-picture mode.
player_holder.alpha = 0f
player_holder?.alpha = 0f
pipReceiver = object : BroadcastReceiver() {
override fun onReceive(
context: Context,
@ -188,7 +192,8 @@ abstract class AbstractPlayerFragment(
updateIsPlaying(Pair(isPlayingValue, isPlayingValue))
} else {
// Restore the full-screen UI.
player_holder.alpha = 1f
player_holder?.alpha = 1f
exitedPipMode()
pipReceiver?.let {
activity?.unregisterReceiver(it)
}

View file

@ -146,6 +146,10 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
return rawY > statusHeight && rawX < screenWidth //- navHeight
}
override fun exitedPipMode() {
animateLayoutChanges()
}
private fun animateLayoutChanges() {
if (isShowing) {
updateUIVisibility()