Skip to content

Commit 2baa764

Browse files
authored
feat(seekbar): use MPV playtime-remaining for speed-scaled remaining timer (#323)
1 parent 72ecd11 commit 2baa764

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

app/src/main/java/live/mehiz/mpvkt/ui/player/controls/PlayerControls.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,12 @@ fun PlayerControls(
408408
) {
409409
val invertDuration by playerPreferences.invertDuration.collectAsState()
410410
val readAhead by MPVLib.propFloat["demuxer-cache-time"].collectAsState()
411+
val remaining by MPVLib.propFloat["playtime-remaining"].collectAsState()
411412
val preciseSeeking by playerPreferences.preciseSeeking.collectAsState()
412413
SeekbarWithTimers(
413414
position = position?.toFloat() ?: 0f,
414415
duration = duration?.toFloat() ?: 0f,
416+
remaining = remaining?.toFloat() ?: 0f,
415417
readAheadValue = readAhead ?: 0f,
416418
onValueChange = {
417419
isSeeking = true

app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/Seekbar.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import live.mehiz.mpvkt.ui.theme.spacing
3232
fun SeekbarWithTimers(
3333
position: Float,
3434
duration: Float,
35+
remaining: Float,
3536
readAheadValue: Float,
3637
onValueChange: (Float) -> Unit,
3738
onValueChangeFinished: () -> Unit,
@@ -74,7 +75,7 @@ fun SeekbarWithTimers(
7475
),
7576
)
7677
VideoTimer(
77-
value = if (timersInverted.second) position - duration else duration,
78+
value = if (timersInverted.second) -remaining else duration,
7879
isInverted = timersInverted.second,
7980
onClick = {
8081
clickEvent()
@@ -114,6 +115,7 @@ private fun PreviewSeekBar() {
114115
SeekbarWithTimers(
115116
5f,
116117
20f,
118+
15f,
117119
4f,
118120
{},
119121
{},

0 commit comments

Comments
 (0)