Skip to content

Commit 8a2f28b

Browse files
author
Florian Renaud
committed
Add comment to explain the error handling
1 parent 9d3b5c5 commit 8a2f28b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

vector/src/main/java/im/vector/app/features/voicebroadcast/listening/VoiceBroadcastPlayerImpl.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
282282
}
283283
} catch (failure: VoiceBroadcastFailure.ListeningError.DownloadError) {
284284
isPreparingNextPlayer = false
285+
// Do not change the playingState if the current player is still valid,
286+
// the error will be thrown again when switching to the next player
285287
if (playingState == State.Buffering || tryOrNull { currentMediaPlayer?.isPlaying } != true) {
286288
playingState = State.Error(failure)
287289
}
@@ -453,6 +455,8 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
453455

454456
override fun onError(mp: MediaPlayer, what: Int, extra: Int): Boolean {
455457
Timber.d("## Voice Broadcast | onError: what=$what, extra=$extra")
458+
// Do not change the playingState if the current player is still valid,
459+
// the error will be thrown again when switching to the next player
456460
if (playingState == State.Buffering || tryOrNull { currentMediaPlayer?.isPlaying } != true) {
457461
playingState = State.Error(VoiceBroadcastFailure.ListeningError.UnableToPlay(what, extra))
458462
}

0 commit comments

Comments
 (0)