mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Merge pull request #713 from leonklingele/keydown-mediakeys-detection
js: add support to detect media keys in keydown handler
This commit is contained in:
commit
3ab3a5a236
1 changed files with 32 additions and 2 deletions
|
@ -231,11 +231,24 @@ function set_time_percent(percent) {
|
|||
player.currentTime(newTime);
|
||||
}
|
||||
|
||||
function play() {
|
||||
player.play();
|
||||
}
|
||||
|
||||
function pause() {
|
||||
player.pause();
|
||||
}
|
||||
|
||||
function stop() {
|
||||
player.pause();
|
||||
player.currentTime(0);
|
||||
}
|
||||
|
||||
function toggle_play() {
|
||||
if (player.paused()) {
|
||||
player.play();
|
||||
play();
|
||||
} else {
|
||||
player.pause();
|
||||
pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,9 +354,22 @@ window.addEventListener('keydown', e => {
|
|||
switch (decoratedKey) {
|
||||
case ' ':
|
||||
case 'k':
|
||||
case 'MediaPlayPause':
|
||||
action = toggle_play;
|
||||
break;
|
||||
|
||||
case 'MediaPlay':
|
||||
action = play;
|
||||
break;
|
||||
|
||||
case 'MediaPause':
|
||||
action = pause;
|
||||
break;
|
||||
|
||||
case 'MediaStop':
|
||||
action = stop;
|
||||
break;
|
||||
|
||||
case 'ArrowUp':
|
||||
if (isPlayerFocused) {
|
||||
action = increase_volume.bind(this, 0.1);
|
||||
|
@ -360,9 +386,11 @@ window.addEventListener('keydown', e => {
|
|||
break;
|
||||
|
||||
case 'ArrowRight':
|
||||
case 'MediaFastForward':
|
||||
action = skip_seconds.bind(this, 5);
|
||||
break;
|
||||
case 'ArrowLeft':
|
||||
case 'MediaTrackPrevious':
|
||||
action = skip_seconds.bind(this, -5);
|
||||
break;
|
||||
case 'l':
|
||||
|
@ -394,9 +422,11 @@ window.addEventListener('keydown', e => {
|
|||
break;
|
||||
|
||||
case 'N':
|
||||
case 'MediaTrackNext':
|
||||
action = next_video;
|
||||
break;
|
||||
case 'P':
|
||||
case 'MediaTrackPrevious':
|
||||
// TODO: Add support to play back previous video.
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue