mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Use Shift+Left/Right to switch video chapters
This commit is contained in:
@@ -22,5 +22,13 @@ var actions = {
|
|||||||
prev_track: {
|
prev_track: {
|
||||||
run: (window) => window.child.player.playlistWidget.prevTrack(),
|
run: (window) => window.child.player.playlistWidget.prevTrack(),
|
||||||
accels: ['<Ctrl>Left'],
|
accels: ['<Ctrl>Left'],
|
||||||
|
},
|
||||||
|
next_chapter: {
|
||||||
|
run: (window) => window.child.player.next_chapter(),
|
||||||
|
accels: ['<Shift>Right'],
|
||||||
|
},
|
||||||
|
prev_chapter: {
|
||||||
|
run: (window) => window.child.player.prev_chapter(),
|
||||||
|
accels: ['<Shift>Left'],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -369,6 +369,16 @@ class ClapperPlayer extends GstClapper.Clapper
|
|||||||
this[action]();
|
this[action]();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next_chapter()
|
||||||
|
{
|
||||||
|
return this._switchChapter(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
prev_chapter()
|
||||||
|
{
|
||||||
|
return this._switchChapter(true);
|
||||||
|
}
|
||||||
|
|
||||||
emitWs(action, value)
|
emitWs(action, value)
|
||||||
{
|
{
|
||||||
if(!this.webserver)
|
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)
|
_addPlaylistItems(playlist)
|
||||||
{
|
{
|
||||||
for(let source of playlist) {
|
for(let source of playlist) {
|
||||||
|
Reference in New Issue
Block a user