Skip to content

Commit

Permalink
use a 'keydown' listener in video/index.js instead
Browse files Browse the repository at this point in the history
  • Loading branch information
shoffing authored and thornbill committed Jul 10, 2024
1 parent e28b557 commit 5ef0428
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
9 changes: 7 additions & 2 deletions src/controllers/playback/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1775,8 +1775,13 @@ export default function (view) {
}
});

nowPlayingPositionSlider.addEventListener('playpause', function () {
playbackManager.playPause(currentPlayer);
nowPlayingPositionSlider.addEventListener('keydown', function (e) {
if (e.defaultPrevented) return;

const key = keyboardnavigation.getKeyName(e);
if (key === 'Enter') {
playbackManager.playPause(currentPlayer);
}
});

nowPlayingPositionSlider.updateBubbleHtml = function(bubble, value) {
Expand Down
19 changes: 2 additions & 17 deletions src/elements/emby-slider/emby-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,19 +521,6 @@ function stepKeyboard(elem, delta) {
elem.dispatchEvent(event);
}

/**
* Play or pause video.
*
* @param {Object} elem slider itself
*/
function playPauseKeyboard(elem) {
const event = new Event('playpause', {
bubbles: true,
cancelable: false
});
elem.dispatchEvent(event);
}

/**
* Handle KeyDown event
*/
Expand All @@ -554,11 +541,9 @@ function onKeyDown(e) {
case 'Enter':
if (this.keyboardDragging) {
finishKeyboardDragging(this);
} else {
playPauseKeyboard(this);
e.preventDefault();
e.stopPropagation();
}
e.preventDefault();
e.stopPropagation();
break;
}
}
Expand Down

0 comments on commit 5ef0428

Please sign in to comment.