Fix an exception when removeIncompleteTracksFromPlaylist() could be called on the wrong thread.

This commit is contained in:
tzugen 2023-07-13 13:19:03 +02:00
parent 7209779b64
commit 8d43b935ab
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930

View File

@ -182,16 +182,19 @@ class MediaPlayerManager(
createMediaController(onCreated)
rxBusSubscription += RxBus.activeServerChangingObservable.subscribe { oldServer ->
if (oldServer != OFFLINE_DB_ID) {
// When the server changes, the playlist can retain the downloaded songs.
// Incomplete songs should be removed as the new server won't recognise them.
removeIncompleteTracksFromPlaylist()
DownloadService.requestStop()
}
if (controller is JukeboxMediaPlayer) {
// When the server changes, the Jukebox should be released.
// The new server won't understand the jukebox requests of the old one.
switchToLocalPlayer()
// Even though Rx should launch on the main thread it doesn't always :(
mainScope.launch {
if (oldServer != OFFLINE_DB_ID) {
// When the server changes, the playlist can retain the downloaded songs.
// Incomplete songs should be removed as the new server won't recognise them.
removeIncompleteTracksFromPlaylist()
DownloadService.requestStop()
}
if (controller is JukeboxMediaPlayer) {
// When the server changes, the Jukebox should be released.
// The new server won't understand the jukebox requests of the old one.
switchToLocalPlayer()
}
}
}