From 5d0876bbf7a880fdb99009d54866968f0a25d708 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Wed, 13 Jan 2021 18:49:10 +0100 Subject: [PATCH] Do not do fast seeks when seeking to chapter Fast seeks are always a little off from requested time. When seeking to chapter position, do it by using a normal seek and restore user selected fast seeks afterwards. --- clapper_src/controls.js | 12 ++++++++++-- clapper_src/player.js | 29 +++++++++++++++++++++++++++-- clapper_src/widget.js | 4 ++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/clapper_src/controls.js b/clapper_src/controls.js index 0c3ffe86..56d51365 100644 --- a/clapper_src/controls.js +++ b/clapper_src/controls.js @@ -585,14 +585,22 @@ class ClapperControls extends Gtk.Box if((this.isPositionDragging = isPositionDragging)) return; + const isChapterSeek = this.chapterPopover.visible; + if(!isPositionDragging) this._setChapterVisible(false); const clapperWidget = this.get_ancestor(Gtk.Grid); if(!clapperWidget) return; - const positionSeconds = Math.round(scale.get_value()); - clapperWidget.player.seek_seconds(positionSeconds); + const scaleValue = scale.get_value(); + + if(!isChapterSeek) { + const positionSeconds = Math.round(scaleValue); + clapperWidget.player.seek_seconds(positionSeconds); + } + else + clapperWidget.player.seek_chapter(scaleValue); } /* Only happens when navigating through controls panel */ diff --git a/clapper_src/player.js b/clapper_src/player.js index 2538355a..7a263b7b 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -20,6 +20,7 @@ class ClapperPlayer extends PlayerBase this.dragAllowed = false; this.isWidgetDragging = false; this.doneStartup = false; + this.needsFastSeekRestore = false; this.playOnFullscreen = false; this.quitOnStop = false; @@ -209,9 +210,26 @@ class ClapperPlayer extends PlayerBase super.seek(position); } - seek_seconds(position) + seek_seconds(seconds) { - this.seek(position * 1000000000); + this.seek(seconds * 1000000000); + } + + seek_chapter(seconds) + { + if(this.seekingMode !== 'fast') { + this.seek_seconds(seconds); + return; + } + + /* FIXME: Remove this check when GstPlay(er) have set_seek_mode function */ + if(this.set_seek_mode) { + this.set_seek_mode(GstPlayer.PlayerSeekMode.DEFAULT); + this.seekingMode = 'normal'; + this.needsFastSeekRestore = true; + } + + this.seek_seconds(seconds); } set_volume(volume) @@ -399,6 +417,13 @@ class ClapperPlayer extends PlayerBase if(!this.seek_done && state !== GstPlayer.PlayerState.BUFFERING) { clapperWidget.updateTime(); + + if(this.needsFastSeekRestore) { + this.set_seek_mode(GstPlayer.PlayerSeekMode.FAST); + this.seekingMode = 'fast'; + this.needsFastSeekRestore = false; + } + this.seek_done = true; debug('seeking finished'); } diff --git a/clapper_src/widget.js b/clapper_src/widget.js index 2b4e50e7..940714bf 100644 --- a/clapper_src/widget.js +++ b/clapper_src/widget.js @@ -388,12 +388,12 @@ class ClapperWidget extends Gtk.Grid return; } - /* FIXME: Use higher precision for position scale */ const pos = Math.floor(start / 1000000) / 1000; + const tags = subentry.get_tags(); + this.controls.positionScale.add_mark(pos, Gtk.PositionType.TOP, null); this.controls.positionScale.add_mark(pos, Gtk.PositionType.BOTTOM, null); - const tags = subentry.get_tags(); if(!tags) { debug('could not obtain toc subentry tags'); return;