From 04ecb7c192b720a2d85bc61920c16dbbcd9e43b5 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Wed, 25 Sep 2024 11:35:43 +0200 Subject: [PATCH 1/3] Tweak CurrentTimeDisplay in default UI when playing live or DVR --- ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt b/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt index e5ee866..f433613 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt @@ -112,7 +112,12 @@ fun DefaultUI( Row(verticalAlignment = Alignment.CenterVertically) { MuteButton() LiveButton() - CurrentTimeDisplay(showDuration = true) + if (player.streamType != StreamType.Live) { + CurrentTimeDisplay( + showRemaining = player.streamType == StreamType.Dvr, + showDuration = player.streamType == StreamType.Vod + ) + } Spacer(modifier = Modifier.weight(1f)) FullscreenButton() } From dd3948982f7600ada1dce18b83d45851d1297aaf Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Wed, 25 Sep 2024 11:39:21 +0200 Subject: [PATCH 2/3] Use seekable end for duration displays --- .../main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt | 2 +- ui/src/main/java/com/theoplayer/android/ui/DurationDisplay.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt b/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt index fa32c76..0b83c76 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/CurrentTimeDisplay.kt @@ -21,7 +21,7 @@ fun CurrentTimeDisplay( ) { val player = Player.current val currentTime = player?.currentTime ?: 0.0 - val duration = player?.duration ?: Double.NaN + val duration = player?.seekable?.lastEnd ?: player?.duration ?: Double.NaN val time = if (showRemaining) { -(duration - currentTime) diff --git a/ui/src/main/java/com/theoplayer/android/ui/DurationDisplay.kt b/ui/src/main/java/com/theoplayer/android/ui/DurationDisplay.kt index 520929a..3527ab3 100644 --- a/ui/src/main/java/com/theoplayer/android/ui/DurationDisplay.kt +++ b/ui/src/main/java/com/theoplayer/android/ui/DurationDisplay.kt @@ -14,7 +14,7 @@ fun DurationDisplay( modifier: Modifier = Modifier ) { val player = Player.current - val duration = player?.duration ?: Double.NaN + val duration = player?.seekable?.lastEnd ?: player?.duration ?: Double.NaN Text(modifier = modifier, text = formatTime(duration)) } \ No newline at end of file From df96e6eceac2da584b167528da2c7caae52c18c1 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Wed, 25 Sep 2024 12:10:10 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64de75f..500b407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ > - 🏠 Internal > - 💅 Polish +## Unreleased + +* 🐛 Fix `DurationDisplay` to show the time of the live point when playing a live or DVR stream. +* 🐛 Fix `CurrentTimeDisplay` to show the time offset to the live point when playing a live or DVR stream with `showRemaining = true`. +* 💅 Changed `DefaultUi` to hide the current time display when playing a live stream. +* 💅 Changed `DefaultUi` to show the time offset to the live point when playing a DVR stream. + ## v1.9.0 (2024-09-10) * 💥 Updated to Jetpack Compose version 1.7.0 ([BOM](https://developer.android.com/jetpack/compose/bom) 2024.09.00).