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,10 +252,12 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
onNextMediaPlayerStarted(mp) onNextMediaPlayerStarted(mp)
} catch (failure: VoiceBroadcastFailure.ListeningError) { } catch (failure: VoiceBroadcastFailure.ListeningError) {
if (failure.cause !is CancellationException) {
playingState = State.Error(failure) playingState = State.Error(failure)
} }
} }
} }
}
private fun pausePlayback() { private fun pausePlayback() {
playingState = State.Paused // This will trigger a playing state update and save the current position playingState = State.Paused // This will trigger a playing state update and save the current position
@ -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)
} }
} }