mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 20:29:10 +03:00
Fix playback position on live broadcast
This commit is contained in:
parent
bdfebac76d
commit
05ffadb0ef
1 changed files with 12 additions and 3 deletions
|
@ -225,11 +225,21 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||
|
||||
private fun startPlayback(position: Int) {
|
||||
stopPlayer()
|
||||
playingState = State.Buffering
|
||||
|
||||
val playlistItem = playlist.findByPosition(position) ?: run { Timber.w("## Voice Broadcast | No content to play at position $position"); return }
|
||||
val sequence = playlistItem.sequence ?: run { Timber.w("## Voice Broadcast | Playlist item has no sequence"); return }
|
||||
val playlistItem = playlist.findByPosition(position) ?: run {
|
||||
Timber.w("## Voice Broadcast | No content to play at position $position"); stop(); return
|
||||
}
|
||||
val sequence = playlistItem.sequence ?: run {
|
||||
Timber.w("## Voice Broadcast | Playlist item has no sequence"); stop(); return
|
||||
}
|
||||
val sequencePosition = position - playlistItem.startTime
|
||||
|
||||
currentVoiceBroadcast?.let {
|
||||
val percentage = tryOrNull { position.toFloat() / playlist.duration } ?: 0f
|
||||
playbackTracker.updatePausedAtPlaybackTime(it.voiceBroadcastId, position, percentage)
|
||||
}
|
||||
|
||||
prepareCurrentPlayerJob = sessionScope.launch {
|
||||
try {
|
||||
val mp = prepareMediaPlayer(playlistItem.audioEvent.content)
|
||||
|
@ -240,7 +250,6 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||
mp.seekTo(sequencePosition)
|
||||
}
|
||||
|
||||
currentVoiceBroadcast?.let { playbackTicker.startPlaybackTicker(it.voiceBroadcastId) }
|
||||
onNextMediaPlayerStarted(mp)
|
||||
} catch (failure: VoiceBroadcastFailure.ListeningError) {
|
||||
playingState = State.Error(failure)
|
||||
|
|
Loading…
Add table
Reference in a new issue