Do not enter in error state in case of cancellation exception

This commit is contained in:
Florian Renaud 2023-01-30 15:21:47 +01:00
parent 3ce757ee4b
commit a0ab6de85a
1 changed files with 4 additions and 2 deletions

View File

@ -252,7 +252,9 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
onNextMediaPlayerStarted(mp) onNextMediaPlayerStarted(mp)
} catch (failure: VoiceBroadcastFailure.ListeningError) { } 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) { } catch (failure: VoiceBroadcastFailure.ListeningError) {
// Do not change the playingState if the current player is still valid, // Do not change the playingState if the current player is still valid,
// the error will be thrown again when switching to the next player // 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) playingState = State.Error(failure)
} }
} }