From 745747b604a839070a4786d394a6681333573c29 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Thu, 15 Oct 2020 22:49:37 +0200 Subject: [PATCH] Hide time and position scale on LIVE media --- clapper_src/controls.js | 22 +++++++++++++++++++++- clapper_src/interface.js | 15 ++++++++------- css/styles.css | 4 ---- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/clapper_src/controls.js b/clapper_src/controls.js index 52b33fa4..8d9aebcc 100644 --- a/clapper_src/controls.js +++ b/clapper_src/controls.js @@ -69,6 +69,18 @@ var Controls = GObject.registerClass({ this.unfullscreenButton.set_visible(isFullscreen); } + setLiveMode(isLive, isSeekable) + { + /* This update must always happen + * after media duration is set */ + let text = (isLive) + ? 'LIVE' + : '00:00:00' + '/' + this.durationFormated; + + this.elapsedButton.set_label(text); + this.positionScale.visible = isSeekable; + } + addButton(buttonIcon) { let button = (buttonIcon instanceof Gtk.Button) @@ -186,6 +198,7 @@ var Controls = GObject.registerClass({ hexpand: true, valign: Gtk.Align.CENTER, can_focus: false, + visible: false, }); this.togglePlayButton.bind_property('margin_top', @@ -206,7 +219,14 @@ var Controls = GObject.registerClass({ ); this.positionAdjustment = this.positionScale.get_adjustment(); - this.append(this.positionScale); + + let box = new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, + hexpand: true, + can_focus: false, + }); + box.append(this.positionScale); + this.append(box); } _addVolumeButton() diff --git a/clapper_src/interface.js b/clapper_src/interface.js index ebfd1cab..896f7ce6 100644 --- a/clapper_src/interface.js +++ b/clapper_src/interface.js @@ -20,6 +20,8 @@ class ClapperInterface extends Gtk.Grid Object.assign(this, defaults, opts); this.fullscreenMode = false; + this.isSeekable = false; + this.lastVolumeValue = null; this.lastPositionValue = 0; this.lastRevealerEventTime = 0; @@ -129,11 +131,10 @@ class ClapperInterface extends Gtk.Grid /* Set titlebar media title and path */ this.updateTitles(mediaInfo); - // we can also check if video is "live" or "seekable" (right now unused) - // it might be a good idea to hide position seek bar and disable seeking - // when playing not seekable media (not implemented yet) - //let isLive = mediaInfo.is_live(); - //let isSeekable = mediaInfo.is_seekable(); + /* Show/hide position scale on LIVE */ + let isLive = mediaInfo.is_live(); + this.isSeekable = mediaInfo.is_seekable(); + this.controls.setLiveMode(isLive, this.isSeekable); let streamList = mediaInfo.get_stream_list(); let parsedInfo = { @@ -323,7 +324,6 @@ class ClapperInterface extends Gtk.Grid this._player.set_visualization_enabled(false); debug('disabled visualizations'); } - return; } @@ -383,7 +383,8 @@ class ClapperInterface extends Gtk.Grid _onPlayerPositionUpdated(player, position) { if( - this.controls.isPositionSeeking + !this.isSeekable + || this.controls.isPositionSeeking || this._player.state === GstPlayer.PlayerState.BUFFERING ) return; diff --git a/css/styles.css b/css/styles.css index 267c24de..9f446a8b 100644 --- a/css/styles.css +++ b/css/styles.css @@ -14,10 +14,6 @@ scale marks { min-width: 36px; min-height: 36px; } -.osd scale trough highlight { - min-width: 0px; - min-height: 6px; -} .osd radio { margin: 6px; border: 2px solid;