Fix closing the audio player

This commit is contained in:
Bnyro 2023-03-11 16:33:53 +01:00
parent 6e3b349e79
commit 02d16ca7f5

View File

@ -140,6 +140,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
} }
binding.close.setOnClickListener { binding.close.setOnClickListener {
activity?.unbindService(connection)
BackgroundHelper.stopBackgroundPlay(requireContext()) BackgroundHelper.stopBackgroundPlay(requireContext())
findNavController().popBackStack() findNavController().popBackStack()
} }
@ -242,7 +243,9 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
override fun onDestroy() { override fun onDestroy() {
// unregister all listeners and the connected [playerService] // unregister all listeners and the connected [playerService]
playerService?.onIsPlayingChanged = null playerService?.onIsPlayingChanged = null
activity?.unbindService(connection) runCatching {
activity?.unbindService(connection)
}
PlayingQueue.removeOnTrackChangedListener(onTrackChangeListener) PlayingQueue.removeOnTrackChangedListener(onTrackChangeListener)
super.onDestroy() super.onDestroy()