mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 20:29:10 +03:00
Stay in live when moving playback position in the same chunk
This commit is contained in:
parent
b85fcf9a00
commit
d9454af63e
1 changed files with 11 additions and 7 deletions
|
@ -343,17 +343,21 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
|
|||
!currentVoiceBroadcastEvent?.isLive.orFalse() -> false
|
||||
// the player is stopped or paused
|
||||
playingState == State.IDLE || playingState == State.PAUSED -> false
|
||||
// the user has sought
|
||||
seekPosition != null -> {
|
||||
val seekDirection = seekPosition.compareTo(getCurrentPlaybackPosition() ?: 0)
|
||||
when {
|
||||
// backward
|
||||
seekDirection < 0 -> false
|
||||
// forward: check if new sequence is the last one
|
||||
else -> playlist.findByPosition(seekPosition)?.sequence == playlist.lastOrNull()?.sequence
|
||||
val newSequence = playlist.findByPosition(seekPosition)?.sequence
|
||||
// the user has sought forward
|
||||
if (seekDirection >= 0) {
|
||||
// stay in live or latest sequence reached
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue