mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-18 13:00:18 +03:00
Handle download error during playback
This commit is contained in:
parent
2d24eb1273
commit
3663f22590
1 changed files with 32 additions and 21 deletions
|
@ -206,6 +206,7 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
||||||
val sequence = playlistItem.sequence ?: run { Timber.w("## Voice Broadcast | Playlist item has no sequence"); return }
|
val sequence = playlistItem.sequence ?: run { Timber.w("## Voice Broadcast | Playlist item has no sequence"); return }
|
||||||
val sequencePosition = position - playlistItem.startTime
|
val sequencePosition = position - playlistItem.startTime
|
||||||
sessionScope.launch {
|
sessionScope.launch {
|
||||||
|
try {
|
||||||
prepareMediaPlayer(content) { mp ->
|
prepareMediaPlayer(content) { mp ->
|
||||||
currentMediaPlayer = mp
|
currentMediaPlayer = mp
|
||||||
playlist.currentSequence = sequence
|
playlist.currentSequence = sequence
|
||||||
|
@ -216,6 +217,9 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
||||||
playingState = State.Playing
|
playingState = State.Playing
|
||||||
prepareNextMediaPlayer()
|
prepareNextMediaPlayer()
|
||||||
}
|
}
|
||||||
|
} catch (failure: VoiceBroadcastFailure.ListeningError.DownloadError) {
|
||||||
|
playingState = State.Error(failure)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +263,7 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
||||||
if (nextItem != null) {
|
if (nextItem != null) {
|
||||||
isPreparingNextPlayer = true
|
isPreparingNextPlayer = true
|
||||||
sessionScope.launch {
|
sessionScope.launch {
|
||||||
|
try {
|
||||||
prepareMediaPlayer(nextItem.audioEvent.content) { mp ->
|
prepareMediaPlayer(nextItem.audioEvent.content) { mp ->
|
||||||
isPreparingNextPlayer = false
|
isPreparingNextPlayer = false
|
||||||
nextMediaPlayer = mp
|
nextMediaPlayer = mp
|
||||||
|
@ -275,6 +280,12 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
||||||
State.Idle -> stopPlayer()
|
State.Idle -> stopPlayer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (failure: VoiceBroadcastFailure.ListeningError.DownloadError) {
|
||||||
|
isPreparingNextPlayer = false
|
||||||
|
if (playingState == State.Buffering || tryOrNull { currentMediaPlayer?.isPlaying } != true) {
|
||||||
|
playingState = State.Error(failure)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue