Stay in live when moving playback position in the same chunk

This commit is contained in:
Florian Renaud 2022-11-15 00:30:55 +01:00
parent b85fcf9a00
commit d9454af63e

View File

@ -343,17 +343,21 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
!currentVoiceBroadcastEvent?.isLive.orFalse() -> false !currentVoiceBroadcastEvent?.isLive.orFalse() -> false
// the player is stopped or paused // the player is stopped or paused
playingState == State.IDLE || playingState == State.PAUSED -> false playingState == State.IDLE || playingState == State.PAUSED -> false
// the user has sought
seekPosition != null -> { seekPosition != null -> {
val seekDirection = seekPosition.compareTo(getCurrentPlaybackPosition() ?: 0) val seekDirection = seekPosition.compareTo(getCurrentPlaybackPosition() ?: 0)
when { val newSequence = playlist.findByPosition(seekPosition)?.sequence
// backward // the user has sought forward
seekDirection < 0 -> false if (seekDirection >= 0) {
// forward: check if new sequence is the last one // stay in live or latest sequence reached
else -> playlist.findByPosition(seekPosition)?.sequence == playlist.lastOrNull()?.sequence isLiveListening || newSequence == playlist.lastOrNull()?.sequence
}
// the user has sought backward
else {
// was in live and stay in the same sequence
isLiveListening && newSequence == playlist.currentSequence
} }
} }
// otherwise, stay in live or go in live if we reached the last sequence // otherwise, stay in live or go in live if we reached the latest sequence
else -> isLiveListening || playlist.currentSequence == playlist.lastOrNull()?.sequence else -> isLiveListening || playlist.currentSequence == playlist.lastOrNull()?.sequence
} }
} }