mirror of
https://github.com/Rafostar/clapper.git
synced 2025-09-02 01:12:02 +02:00
Use Shift+Left/Right to switch video chapters
This commit is contained in:
@@ -369,6 +369,16 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
this[action]();
|
||||
}
|
||||
|
||||
next_chapter()
|
||||
{
|
||||
return this._switchChapter(false);
|
||||
}
|
||||
|
||||
prev_chapter()
|
||||
{
|
||||
return this._switchChapter(true);
|
||||
}
|
||||
|
||||
emitWs(action, value)
|
||||
{
|
||||
if(!this.webserver)
|
||||
@@ -409,6 +419,30 @@ class ClapperPlayer extends GstClapper.Clapper
|
||||
}
|
||||
}
|
||||
|
||||
_switchChapter(isPrevious)
|
||||
{
|
||||
if(this.state === GstClapper.ClapperState.STOPPED)
|
||||
return false;
|
||||
|
||||
const { chapters } = this.widget.root.child.controls;
|
||||
if(!chapters)
|
||||
return false;
|
||||
|
||||
const now = this.position / Gst.SECOND;
|
||||
let chapterTimes = Object.keys(chapters);
|
||||
if(isPrevious)
|
||||
chapterTimes.reverse();
|
||||
|
||||
const chapter = chapterTimes.find(time => (isPrevious)
|
||||
? now - 2.5 > time
|
||||
: now < time
|
||||
);
|
||||
if(!chapter)
|
||||
return false;
|
||||
|
||||
this.seek_chapter(chapter);
|
||||
}
|
||||
|
||||
_addPlaylistItems(playlist)
|
||||
{
|
||||
for(let source of playlist) {
|
||||
|
Reference in New Issue
Block a user