From c2d5908542d9a25f3b542d768f5defc8bf18f4ec Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Thu, 24 Nov 2022 18:10:36 +0100 Subject: [PATCH] Stop playback if live broadcast has ended and there is no more chunk to listen --- .../voicebroadcast/listening/VoiceBroadcastPlayerImpl.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/VoiceBroadcastPlayerImpl.kt b/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/VoiceBroadcastPlayerImpl.kt index f68e546809..addaaeec30 100644 --- a/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/VoiceBroadcastPlayerImpl.kt +++ b/vector/src/main/java/im/vector/app/features/voicebroadcast/listening/VoiceBroadcastPlayerImpl.kt @@ -376,6 +376,11 @@ class VoiceBroadcastPlayerImpl @Inject constructor( // Notify live mode change to all the listeners attached to the current voice broadcast id listeners[voiceBroadcastId]?.forEach { listener -> listener.onLiveModeChanged(isLiveListening) } } + + // Live has ended and last chunk has been reached, we can stop the playback + if (!isLiveListening && playingState == State.BUFFERING && playlist.currentSequence == mostRecentVoiceBroadcastEvent?.content?.lastChunkSequence) { + stop() + } } private fun onNextMediaPlayerStarted(mp: MediaPlayer) {