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