From eafc65d15d3e172fc4e58fe5afebb7379214a086 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Fri, 16 Oct 2020 12:13:00 +0200 Subject: [PATCH] Go back to beginning after playback ends --- clapper_src/controls.js | 3 +++ clapper_src/interface.js | 9 ++++++++- clapper_src/player.js | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clapper_src/controls.js b/clapper_src/controls.js index 0a0bb657..b37b35bf 100644 --- a/clapper_src/controls.js +++ b/clapper_src/controls.js @@ -162,6 +162,9 @@ var Controls = GObject.registerClass({ handleScaleIncrement(type, isUp) { + if(type === 'volume' && !this.volumeButton.visible) + return; + let value = this[`${type}Scale`].get_value(); let maxValue = this[`${type}Adjustment`].get_upper(); let increment = this[`${type}Adjustment`].get_page_increment(); diff --git a/clapper_src/interface.js b/clapper_src/interface.js index 2d50e4ca..3cfaf60e 100644 --- a/clapper_src/interface.js +++ b/clapper_src/interface.js @@ -349,12 +349,14 @@ class ClapperInterface extends Gtk.Grid this.needsTracksUpdate = true; break; case GstPlayer.PlayerState.STOPPED: + this.lastPositionValue = 0; + this.controls.positionAdjustment.set_value(0); + this.controls.togglePlayButton.setPrimaryIcon(); this.needsTracksUpdate = true; if(this.mediaInfoSignal) { this._player.disconnect(this.mediaInfoSignal); this.mediaInfoSignal = null; } - break; case GstPlayer.PlayerState.PAUSED: this.controls.togglePlayButton.setPrimaryIcon(); break; @@ -443,6 +445,11 @@ class ClapperInterface extends Gtk.Grid this.lastPositionValue = positionSeconds; this._player.seek_seconds(positionSeconds); + debug(`player is seeking to position: ${positionSeconds}`); + + /* Needed to enable preview after playback is stopped */ + if(this._player.state === GstPlayer.PlayerState.STOPPED) + this._player.pause(); if(this.fullscreenMode) this.updateTime(); diff --git a/clapper_src/player.js b/clapper_src/player.js index be22c1fb..ea716548 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -266,6 +266,8 @@ class ClapperPlayer extends GstPlayer.Player if(this._trackId < this._playlist.length) this.set_media(this._playlist[this._trackId]); + else + this.stop(); } _onUriLoaded()