From fa1455556b4c853efbb4920a4247292c24e3411f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 9 Apr 2021 16:07:11 +0200 Subject: [PATCH] Treat media without duration as live content --- src/revealers.js | 12 +++++++----- src/widget.js | 9 ++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/revealers.js b/src/revealers.js index d6eb8bac..8e99de7e 100644 --- a/src/revealers.js +++ b/src/revealers.js @@ -151,14 +151,16 @@ class ClapperRevealerTop extends CustomRevealer return this.mediaTitle.visible; } - setTimes(currTime, endTime) + setTimes(currTime, endTime, isEndKnown) { const now = currTime.format(this.timeFormat); - const end = endTime.format(this.timeFormat); - const endText = `Ends at: ${end}`; + this.currentTime.label = now; - this.currentTime.set_label(now); - this.endTime.set_label(endText); + const end = (isEndKnown) + ? endTime.format(this.timeFormat) + : 'unknown'; + + this.endTime.label = `Ends at: ${end}`; /* Make sure that next timeout is always run after clock changes, * by delaying it for additional few milliseconds */ diff --git a/src/widget.js b/src/widget.js index de24d6cf..3140d712 100644 --- a/src/widget.js +++ b/src/widget.js @@ -198,9 +198,12 @@ class ClapperWidget extends Gtk.Grid /* Set titlebar media title */ this.updateTitle(mediaInfo); + /* FIXME: replace number with Gst.CLOCK_TIME_NONE when GJS + * can do UINT64: https://gitlab.gnome.org/GNOME/gjs/-/merge_requests/524 */ + const isLive = (mediaInfo.is_live() || player.duration === 18446744073709552000); + this.isSeekable = (!isLive && mediaInfo.is_seekable()); + /* Show/hide position scale on LIVE */ - const isLive = mediaInfo.is_live(); - this.isSeekable = mediaInfo.is_seekable(); this.controls.setLiveMode(isLive, this.isSeekable); /* Update remaining end time if visible */ @@ -339,7 +342,7 @@ class ClapperWidget extends Gtk.Grid const endTime = currTime.add_seconds( this.controls.positionAdjustment.get_upper() - this.controls.currentPosition ); - const nextUpdate = this.revealerTop.setTimes(currTime, endTime); + const nextUpdate = this.revealerTop.setTimes(currTime, endTime, this.isSeekable); return nextUpdate; }