From 15eeea2872c8a11877b4cb67946ab6cdd0945219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 8 Feb 2021 20:02:19 +0100 Subject: [PATCH] Save resume info of last unfinished video --- data/com.github.rafostar.Clapper.gschema.xml | 8 ++++++++ src/player.js | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/data/com.github.rafostar.Clapper.gschema.xml b/data/com.github.rafostar.Clapper.gschema.xml index f0789201..93c3e91a 100644 --- a/data/com.github.rafostar.Clapper.gschema.xml +++ b/data/com.github.rafostar.Clapper.gschema.xml @@ -32,6 +32,14 @@ "second" Unit to use with seeking value + + true + Ask to resume unfinished video + + + '[]' + Data storing unfinished videos resume info + diff --git a/src/player.js b/src/player.js index f6092ea0..36da0d8c 100644 --- a/src/player.js +++ b/src/player.js @@ -372,6 +372,18 @@ class ClapperPlayer extends PlayerBase if(size[0] > 0 && size[1] > 0) clapperWidget._saveWindowSize(size); } + if(this.state !== GstClapper.ClapperState.STOPPED) { + let resumeInfo = {}; + if(settings.get_boolean('resume-enabled')) { + resumeInfo.title = this.playlistWidget.getActiveFilename(); + resumeInfo.time = Math.floor(this.position / 1000000000); + resumeInfo.duration = this.duration / 1000000000; + + debug(`saving resume info for: ${resumeInfo.title}`); + debug(`resume time: ${resumeInfo.time}, duration: ${resumeInfo.duration}`); + } + settings.set_string('resume-database', JSON.stringify([resumeInfo])); + } settings.set_double('volume-last', this.volume); clapperWidget.controls._onCloseRequest();