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