From a0ab6de85aff6ba88360935b1bcf2c02d85c9ee8 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Mon, 30 Jan 2023 15:21:47 +0100 Subject: [PATCH] Do not enter in error state in case of cancellation exception --- .../voicebroadcast/listening/VoiceBroadcastPlayerImpl.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 2be4072bad..61e4bf640c 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 @@ -252,7 +252,9 @@ class VoiceBroadcastPlayerImpl @Inject constructor( onNextMediaPlayerStarted(mp) } catch (failure: VoiceBroadcastFailure.ListeningError) { - playingState = State.Error(failure) + if (failure.cause !is CancellationException) { + playingState = State.Error(failure) + } } } } @@ -313,7 +315,7 @@ class VoiceBroadcastPlayerImpl @Inject constructor( } catch (failure: VoiceBroadcastFailure.ListeningError) { // Do not change the playingState if the current player is still valid, // the error will be thrown again when switching to the next player - if (playingState == State.Buffering || tryOrNull { currentMediaPlayer?.isPlaying } != true) { + if (failure.cause !is CancellationException && (playingState == State.Buffering || tryOrNull { currentMediaPlayer?.isPlaying } != true)) { playingState = State.Error(failure) } }