Skip to content

Commit

Permalink
Use duration when seekable is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Jul 30, 2024
1 parent 7aea6a8 commit 08d9ac1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ui/src/main/java/com/theoplayer/android/ui/SeekBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ fun SeekBar(
val player = Player.current
val currentTime = player?.currentTime?.toFloat() ?: 0.0f
val seekable = player?.seekable ?: TimeRanges.empty()
val duration = player?.duration ?: Double.NaN
val playingAd = player?.playingAd ?: false
val enabled = seekable.isNotEmpty() && !playingAd

val valueRange = remember(seekable) {
val bounds = seekable.bounds ?: 0.0..0.0
bounds.start.toFloat()..bounds.endInclusive.toFloat()
val valueRange = remember(seekable, duration) {
seekable.bounds?.let { bounds ->
bounds.start.toFloat()..bounds.endInclusive.toFloat()
} ?: run {
0f..(if (duration.isFinite()) duration.toFloat() else 0f)
}
}
var seekTime by remember { mutableStateOf<Float?>(null) }
var wasPlayingBeforeSeek by remember { mutableStateOf(false) }
Expand Down

0 comments on commit 08d9ac1

Please sign in to comment.