Save resume info of last unfinished video

This commit is contained in:
Rafał Dzięgiel
2021-02-08 20:02:19 +01:00
parent 84232f3c12
commit 15eeea2872
2 changed files with 20 additions and 0 deletions

View File

@@ -32,6 +32,14 @@
<default>"second"</default> <default>"second"</default>
<summary>Unit to use with seeking value</summary> <summary>Unit to use with seeking value</summary>
</key> </key>
<key name="resume-enabled" type="b">
<default>true</default>
<summary>Ask to resume unfinished video</summary>
</key>
<key name="resume-database" type="s">
<default>'[]'</default>
<summary>Data storing unfinished videos resume info</summary>
</key>
<!-- Audio --> <!-- Audio -->
<key name="audio-offset" type="d"> <key name="audio-offset" type="d">

View File

@@ -372,6 +372,18 @@ class ClapperPlayer extends PlayerBase
if(size[0] > 0 && size[1] > 0) if(size[0] > 0 && size[1] > 0)
clapperWidget._saveWindowSize(size); 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); settings.set_double('volume-last', this.volume);
clapperWidget.controls._onCloseRequest(); clapperWidget.controls._onCloseRequest();