Fix shortcuts

This commit is contained in:
Thomas Forgione 2020-10-08 17:25:17 +02:00
parent c8664f2375
commit 082817a521
1 changed files with 32 additions and 24 deletions

View File

@ -324,12 +324,18 @@ const vd = (function() {
return; return;
} }
let p = document.getElementById(player.id());
if (p === null) {
return;
}
p = typeof p.player === "function" ? p.player() : p.player;
switch (e.keyCode) { switch (e.keyCode) {
case 37: e.preventDefault(); player.currentTime(player.currentTime() - 5); break; case 37: e.preventDefault(); p.currentTime(p.currentTime() - 5); break;
case 39: e.preventDefault(); player.currentTime(player.currentTime() + 5); break; case 39: e.preventDefault(); p.currentTime(p.currentTime() + 5); break;
case 32: e.preventDefault(); if (player.paused()) player.play(); else player.pause(); break; case 32: e.preventDefault(); if (p.paused()) p.play(); else p.pause(); break;
case 40: e.preventDefault(); player.volume(player.volume() - 0.1); break; case 40: e.preventDefault(); p.volume(p.volume() - 0.1); break;
case 38: e.preventDefault(); player.volume(player.volume() + 0.1); break; case 38: e.preventDefault(); p.volume(p.volume() + 0.1); break;
} }
}, true); }, true);
@ -338,20 +344,22 @@ const vd = (function() {
return; return;
} }
let p = document.getElementById(player.id());
if (p === null) {
return;
}
p = typeof p.player === "function" ? p.player() : p.player;
switch (e.keyCode) { switch (e.keyCode) {
case 74: e.preventDefault(); player.currentTime(player.currentTime() - 10); break; // J -> -10s case 74: e.preventDefault(); p.currentTime(p.currentTime() - 10); break; // J -> -10s
case 76: e.preventDefault(); player.currentTime(player.currentTime() + 10); break; // L -> +10s case 76: e.preventDefault(); p.currentTime(p.currentTime() + 10); break; // L -> +10s
case 75: e.preventDefault(); if (player.paused()) player.play(); else player.pause(); break; // K -> play/pause case 75: e.preventDefault(); if (p.paused()) p.play(); else p.pause(); break; // K -> play/pause
case 77: e.preventDefault(); player.muted(!player.muted()); break; // M -> mute case 77: e.preventDefault(); p.muted(!p.muted()); break; // M -> mute
// F -> toggle fullscreen // F -> toggle fullscreen
case 70: case 70:
e.preventDefault(); e.preventDefault();
let p = document.getElementById(player.id());
if (p === null) {
break;
}
p = typeof p.player === "function" ? p.player() : p.player;
if (p.isFullscreen()) { if (p.isFullscreen()) {
p.exitFullscreen(); p.exitFullscreen();
} else { } else {
@ -360,16 +368,16 @@ const vd = (function() {
break; break;
// Seek shortcuts // Seek shortcuts
case 48: case 96: e.preventDefault(); player.currentTime(0); break; case 48: case 96: e.preventDefault(); p.currentTime(0); break;
case 49: case 97: e.preventDefault(); player.currentTime( player.duration() / 10); break; case 49: case 97: e.preventDefault(); p.currentTime( p.duration() / 10); break;
case 50: case 98: e.preventDefault(); player.currentTime(2 * player.duration() / 10); break; case 50: case 98: e.preventDefault(); p.currentTime(2 * p.duration() / 10); break;
case 51: case 99: e.preventDefault(); player.currentTime(3 * player.duration() / 10); break; case 51: case 99: e.preventDefault(); p.currentTime(3 * p.duration() / 10); break;
case 52: case 100: e.preventDefault(); player.currentTime(4 * player.duration() / 10); break; case 52: case 100: e.preventDefault(); p.currentTime(4 * p.duration() / 10); break;
case 53: case 101: e.preventDefault(); player.currentTime(5 * player.duration() / 10); break; case 53: case 101: e.preventDefault(); p.currentTime(5 * p.duration() / 10); break;
case 54: case 102: e.preventDefault(); player.currentTime(6 * player.duration() / 10); break; case 54: case 102: e.preventDefault(); p.currentTime(6 * p.duration() / 10); break;
case 55: case 103: e.preventDefault(); player.currentTime(7 * player.duration() / 10); break; case 55: case 103: e.preventDefault(); p.currentTime(7 * p.duration() / 10); break;
case 56: case 104: e.preventDefault(); player.currentTime(8 * player.duration() / 10); break; case 56: case 104: e.preventDefault(); p.currentTime(8 * p.duration() / 10); break;
case 57: case 105: e.preventDefault(); player.currentTime(9 * player.duration() / 10); break; case 57: case 105: e.preventDefault(); p.currentTime(9 * p.duration() / 10); break;
} }
}, true); }, true);
} }