Handle voice broadcast deletion on listener side

This commit is contained in:
Florian Renaud 2022-11-23 14:10:44 +01:00
parent 2d60e49205
commit f436de1230

View file

@ -145,19 +145,25 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
playingState = State.BUFFERING playingState = State.BUFFERING
observeVoiceBroadcastLiveState(voiceBroadcast) observeVoiceBroadcastStateEvent(voiceBroadcast)
fetchPlaylistAndStartPlayback(voiceBroadcast) fetchPlaylistAndStartPlayback(voiceBroadcast)
} }
private fun observeVoiceBroadcastLiveState(voiceBroadcast: VoiceBroadcast) { private fun observeVoiceBroadcastStateEvent(voiceBroadcast: VoiceBroadcast) {
voiceBroadcastStateObserver = getVoiceBroadcastEventUseCase.execute(voiceBroadcast) voiceBroadcastStateObserver = getVoiceBroadcastEventUseCase.execute(voiceBroadcast)
.onEach { .onEach { onVoiceBroadcastStateEventUpdated(it.getOrNull()) }
currentVoiceBroadcastEvent = it.getOrNull()
updateLiveListeningMode()
}
.launchIn(sessionScope) .launchIn(sessionScope)
} }
private fun onVoiceBroadcastStateEventUpdated(event: VoiceBroadcastEvent?) {
if (event == null) {
stop()
} else {
currentVoiceBroadcastEvent = event
updateLiveListeningMode()
}
}
private fun fetchPlaylistAndStartPlayback(voiceBroadcast: VoiceBroadcast) { private fun fetchPlaylistAndStartPlayback(voiceBroadcast: VoiceBroadcast) {
fetchPlaylistTask = getLiveVoiceBroadcastChunksUseCase.execute(voiceBroadcast) fetchPlaylistTask = getLiveVoiceBroadcastChunksUseCase.execute(voiceBroadcast)
.onEach { .onEach {