fix: crash when player fragment is being destroyed

This commit is contained in:
Bnyro 2023-12-04 15:10:58 +01:00
parent bdd15e0304
commit 82a278792a

View File

@ -779,16 +779,16 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
if (this::exoPlayer.isInitialized) {
if (viewModel.player == exoPlayer) viewModel.player = null if (viewModel.player == exoPlayer) viewModel.player = null
if (this::exoPlayer.isInitialized) exoPlayer.pause() exoPlayer.pause()
// disable the auto PiP mode for SDK >= 32
if (PlayerHelper.pipEnabled) { if (PlayerHelper.pipEnabled) {
PictureInPictureCompat.setPictureInPictureParams( // disable the auto PiP mode for SDK >= 32
requireActivity(), PictureInPictureCompat
pipParams .setPictureInPictureParams(requireActivity(), pipParams)
) }
} }
handler.removeCallbacksAndMessages(null) handler.removeCallbacksAndMessages(null)