Skip to content

Commit

Permalink
Improve time display for live streams (#44)
Browse files Browse the repository at this point in the history
* Tweak CurrentTimeDisplay in default UI when playing live or DVR

* Use seekable end for duration displays

* Update changelog
  • Loading branch information
MattiasBuelens authored Sep 27, 2024
1 parent f8a0439 commit 4ec979e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion ui/src/main/java/com/theoplayer/android/ui/DefaultUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit 4ec979e

Please sign in to comment.