mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-16 09:20:37 +03:00
Fixed restarting after player service stop
This commit is contained in:
parent
10c9095f5f
commit
9319be2d5a
@ -85,12 +85,14 @@ class PlaybackService :
|
||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||
Timber.i("Stopping the playback because we were swiped away")
|
||||
releasePlayerAndSession()
|
||||
super.onTaskRemoved(rootIntent)
|
||||
}
|
||||
|
||||
private fun releasePlayerAndSession() {
|
||||
// Broadcast that the service is being shutdown
|
||||
RxBus.stopServiceCommandPublisher.onNext(Unit)
|
||||
|
||||
// TODO Save the player state before shutdown
|
||||
player.removeListener(listener)
|
||||
player.release()
|
||||
mediaLibrarySession.release()
|
||||
|
@ -198,13 +198,10 @@ class MediaPlayerController(
|
||||
}
|
||||
|
||||
rxBusSubscription += RxBus.shutdownCommandObservable.subscribe {
|
||||
playbackStateSerializer.serializeNow(
|
||||
playlist.map { it.toTrack() },
|
||||
currentMediaItemIndex,
|
||||
playerPosition,
|
||||
isShufflePlayEnabled,
|
||||
repeatMode
|
||||
)
|
||||
clear(false)
|
||||
onDestroy()
|
||||
}
|
||||
rxBusSubscription += RxBus.stopServiceCommandObservable.subscribe {
|
||||
clear(false)
|
||||
onDestroy()
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
||||
rxBusSubscription += RxBus.shutdownCommandObservable.subscribe {
|
||||
onDestroy()
|
||||
}
|
||||
rxBusSubscription += RxBus.stopServiceCommandObservable.subscribe {
|
||||
onDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
fun onCreate() {
|
||||
@ -89,6 +92,7 @@ class MediaPlayerLifecycleSupport : KoinComponent {
|
||||
private fun onDestroy() {
|
||||
|
||||
if (!created) return
|
||||
rxBusSubscription.dispose()
|
||||
|
||||
applicationContext().unregisterReceiver(headsetEventReceiver)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user