Skip to content

Commit

Permalink
Merge pull request #3337 from Bnyro/master
Browse files Browse the repository at this point in the history
Fix that queue controls are visible while player closed
  • Loading branch information
Bnyro authored Mar 21, 2023
2 parents 2bd4ccf + 38be961 commit 40c4391
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions {

saveWatchPosition()

PlayingQueue.clear()

// release the player
nowPlayingNotification.destroySelfAndPlayer()

Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 40c4391

Please sign in to comment.