Add keybind to navigate next.

Closes #1278
This commit is contained in:
Kavin 2022-08-06 15:33:31 +05:30
parent 8e458f4a0e
commit a574cedea3
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -85,7 +85,7 @@ export default {
this.hotkeysPromise.then(() => { this.hotkeysPromise.then(() => {
var self = this; var self = this;
this.$hotkeys( this.$hotkeys(
"f,m,j,k,l,c,space,up,down,left,right,0,1,2,3,4,5,6,7,8,9,shift+,,shift+.", "f,m,j,k,l,c,space,up,down,left,right,0,1,2,3,4,5,6,7,8,9,shift+n,shift+,,shift+.",
function (e, handler) { function (e, handler) {
const videoEl = self.$refs.videoEl; const videoEl = self.$refs.videoEl;
switch (handler.key) { switch (handler.key) {
@ -171,6 +171,10 @@ export default {
videoEl.currentTime = videoEl.duration * 0.9; videoEl.currentTime = videoEl.duration * 0.9;
e.preventDefault(); e.preventDefault();
break; break;
case "shift+n":
self.navigateNext();
e.preventDefault();
break;
case "shift+,": case "shift+,":
self.$player.trickPlay(Math.max(videoEl.playbackRate - 0.25, 0.25)); self.$player.trickPlay(Math.max(videoEl.playbackRate - 0.25, 0.25));
break; break;
@ -372,30 +376,12 @@ export default {
}); });
videoEl.addEventListener("ended", () => { videoEl.addEventListener("ended", () => {
if (!this.selectedAutoLoop && this.selectedAutoPlay && this.video.relatedStreams.length > 0) { if (
const params = this.$route.query; !this.selectedAutoLoop &&
let url = this.playlist?.relatedStreams?.[this.index]?.url ?? this.video.relatedStreams[0].url; this.selectedAutoPlay &&
const searchParams = new URLSearchParams(); (this.playlist?.relatedStreams?.length > 0 || this.video.relatedStreams.length > 0)
for (var param in params) ) {
switch (param) { this.navigateNext();
case "v":
case "t":
break;
case "index":
if (this.index < this.playlist.relatedStreams.length)
searchParams.set("index", this.index + 1);
break;
case "list":
if (this.index < this.playlist.relatedStreams.length)
searchParams.set("list", params.list);
break;
default:
searchParams.set(param, params[param]);
break;
}
const paramStr = searchParams.toString();
if (paramStr.length > 0) url += "&" + paramStr;
this.$router.push(url);
} }
}); });
} }
@ -558,6 +544,29 @@ export default {
this.$refs.videoEl.currentTime = time; this.$refs.videoEl.currentTime = time;
} }
}, },
navigateNext() {
const params = this.$route.query;
let url = this.playlist?.relatedStreams?.[this.index]?.url ?? this.video.relatedStreams[0].url;
const searchParams = new URLSearchParams();
for (var param in params)
switch (param) {
case "v":
case "t":
break;
case "index":
if (this.index < this.playlist.relatedStreams.length) searchParams.set("index", this.index + 1);
break;
case "list":
if (this.index < this.playlist.relatedStreams.length) searchParams.set("list", params.list);
break;
default:
searchParams.set(param, params[param]);
break;
}
const paramStr = searchParams.toString();
if (paramStr.length > 0) url += "&" + paramStr;
this.$router.push(url);
},
updateMarkers() { updateMarkers() {
const markers = this.$refs.container.querySelector(".shaka-ad-markers"); const markers = this.$refs.container.querySelector(".shaka-ad-markers");
const array = ["to right"]; const array = ["to right"];