From d1f32955b848c9fb7ae049f37000558cd1e358f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Mon, 8 Feb 2021 22:16:49 +0100 Subject: [PATCH] Do not save resume info under certain conditions Do not save when video is short, just started or almost finished --- src/player.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/player.js b/src/player.js index 4c9f3858..c57597ac 100644 --- a/src/player.js +++ b/src/player.js @@ -376,12 +376,20 @@ class ClapperPlayer extends PlayerBase if(this.state !== GstClapper.ClapperState.STOPPED && !this.quitOnStop) { 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; + const resumeTime = Math.floor(this.position / 1000000000); + const resumeDuration = this.duration / 1000000000; - debug(`saving resume info for: ${resumeInfo.title}`); - debug(`resume time: ${resumeInfo.time}, duration: ${resumeInfo.duration}`); + /* Do not save resume info when video is short, just started or almost finished */ + if(resumeDuration > 60 && resumeTime > 15 && resumeDuration - resumeTime > 20) { + resumeInfo.title = this.playlistWidget.getActiveFilename(); + resumeInfo.time = resumeTime; + resumeInfo.duration = resumeDuration; + + debug(`saving resume info for: ${resumeInfo.title}`); + debug(`resume time: ${resumeInfo.time}, duration: ${resumeInfo.duration}`); + } + else + debug('resume info is not worth saving'); } settings.set_string('resume-database', JSON.stringify([resumeInfo])); }