Fix that queue controls are visible while player closed

This commit is contained in:
Bnyro 2023-03-21 19:32:00 +01:00
parent 9ff86d3155
commit 38be961011
2 changed files with 7 additions and 4 deletions

View File

@ -364,7 +364,8 @@ class BackgroundMode : LifecycleService() {
* destroy the [BackgroundMode] foreground service
*/
override fun onDestroy() {
// clear the playing queue
// clear and reset the playing queue
PlayingQueue.clear()
PlayingQueue.resetToDefaults()
if (this::nowPlayingNotification.isInitialized) nowPlayingNotification.destroySelfAndPlayer()

View File

@ -584,6 +584,8 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions {
saveWatchPosition()
PlayingQueue.clear()
// release the player
nowPlayingNotification.destroySelfAndPlayer()
@ -644,18 +646,18 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions {
// reset the comments to become reloaded later
commentsViewModel.reset()
lifecycleScope.launchWhenCreated {
lifecycleScope.launch(Dispatchers.IO) {
streams = try {
RetrofitInstance.api.getStreams(videoId!!)
} catch (e: IOException) {
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_LONG).show()
return@launchWhenCreated
return@launch
} catch (e: HttpException) {
val errorMessage = e.response()?.errorBody()?.string()?.runCatching {
JsonHelper.json.decodeFromString<Message>(this).message
}?.getOrNull() ?: context?.getString(R.string.server_error) ?: ""
Toast.makeText(context, errorMessage, Toast.LENGTH_LONG).show()
return@launchWhenCreated
return@launch
}
if (PlayingQueue.isEmpty()) {