mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix pause
This commit is contained in:
parent
031e1c0f26
commit
bd170633c5
1 changed files with 23 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
import { playbackManager } from '../../../components/playback/playbackmanager';
|
||||
import SyncPlay from '../../../components/syncPlay/core';
|
||||
import browser from '../../../scripts/browser';
|
||||
import dom from '../../../scripts/dom';
|
||||
import inputManager from '../../../scripts/inputManager';
|
||||
import mouseManager from '../../../scripts/mouseManager';
|
||||
|
@ -987,17 +988,29 @@ import { appRouter } from '../../../components/appRouter';
|
|||
*/
|
||||
let clickedElement;
|
||||
|
||||
function onClickCapture(e) {
|
||||
// Firefox/Edge emits `click` even if `preventDefault` was used on `keydown`
|
||||
// Ignore 'click' if another element was originally clicked
|
||||
if (!e.target.contains(clickedElement)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onKeyDown(e) {
|
||||
clickedElement = e.target;
|
||||
|
||||
const key = keyboardnavigation.getKeyName(e);
|
||||
const isKeyModified = e.ctrlKey || e.altKey || e.metaKey;
|
||||
const currentElement = document.activeElement;
|
||||
|
||||
if (e.keyCode === 32) {
|
||||
if (!currentElement.className.split(' ').includes('btnPause')) {
|
||||
// If the focused button is the pause button it will already play/pause it
|
||||
if (e.target.tagName !== 'BUTTON' || !layoutManager.tv) {
|
||||
playbackManager.playPause(currentPlayer);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Trick Firefox with a null element to skip next click
|
||||
clickedElement = null;
|
||||
}
|
||||
showOsd();
|
||||
return;
|
||||
|
@ -1308,6 +1321,9 @@ import { appRouter } from '../../../components/appRouter';
|
|||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
if (browser.firefox || browser.edge) {
|
||||
dom.addEventListener(document, 'click', onClickCapture, { capture: true });
|
||||
}
|
||||
} catch (e) {
|
||||
appRouter.goHome();
|
||||
}
|
||||
|
@ -1346,6 +1362,9 @@ import { appRouter } from '../../../components/appRouter';
|
|||
capture: true,
|
||||
passive: true
|
||||
});
|
||||
if (browser.firefox || browser.edge) {
|
||||
dom.removeEventListener(document, 'click', onClickCapture, { capture: true });
|
||||
}
|
||||
stopOsdHideTimer();
|
||||
headerElement.classList.remove('osdHeader');
|
||||
headerElement.classList.remove('osdHeader-hidden');
|
||||
|
@ -1495,10 +1514,7 @@ import { appRouter } from '../../../components/appRouter';
|
|||
playbackManager.previousTrack(currentPlayer);
|
||||
});
|
||||
view.querySelector('.btnPause').addEventListener('click', function () {
|
||||
// Ignore 'click' if another element was originally clicked (Firefox/Edge issue)
|
||||
if (this.contains(clickedElement)) {
|
||||
playbackManager.playPause(currentPlayer);
|
||||
}
|
||||
playbackManager.playPause(currentPlayer);
|
||||
});
|
||||
view.querySelector('.btnNextTrack').addEventListener('click', function () {
|
||||
playbackManager.nextTrack(currentPlayer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue