From abadd23fb4e28846624a7e557ff0b373f2f7e324 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 22 Mar 2023 11:20:20 +0100 Subject: [PATCH] Fix crashes on audio player transitions --- .../github/libretube/ui/fragments/AudioPlayerFragment.kt | 5 ++--- .../com/github/libretube/ui/fragments/PlayerFragment.kt | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt index 1cb7b97e0..09ab9819c 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt @@ -17,7 +17,6 @@ import androidx.constraintlayout.motion.widget.MotionLayout import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.fragment.app.commit -import androidx.navigation.fragment.findNavController import com.github.libretube.R import com.github.libretube.api.obj.StreamItem import com.github.libretube.databinding.FragmentAudioPlayerBinding @@ -123,6 +122,8 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { } binding.openVideo.setOnClickListener { + BackgroundHelper.stopBackgroundPlay(requireContext()) + killFragment() NavigationHelper.navigateVideo( context = requireContext(), videoId = PlayingQueue.getCurrent()?.url?.toID(), @@ -130,8 +131,6 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { keepQueue = true, forceVideo = true ) - BackgroundHelper.stopBackgroundPlay(requireContext()) - findNavController().popBackStack() } binding.share.setOnClickListener { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 1b3cdbb50..7245a5629 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -478,10 +478,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { keepQueue = true, keepVideoPlayerAlive = true ) - handler.postDelayed(500) { - NavigationHelper.startAudioPlayer(requireContext()) - killPlayerFragment() - } + killPlayerFragment() + NavigationHelper.startAudioPlayer(requireContext()) } private fun setFullscreen() {