mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
commit
04b2763447
1 changed files with 68 additions and 35 deletions
|
@ -66,6 +66,10 @@ import 'css!assets/css/videoosd';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOpenedDialog() {
|
||||||
|
return document.querySelector('.dialogContainer .dialog.opened');
|
||||||
|
}
|
||||||
|
|
||||||
export default function (view, params) {
|
export default function (view, params) {
|
||||||
function onVerticalSwipe(e, elem, data) {
|
function onVerticalSwipe(e, elem, data) {
|
||||||
const player = currentPlayer;
|
const player = currentPlayer;
|
||||||
|
@ -354,21 +358,15 @@ import 'css!assets/css/videoosd';
|
||||||
osdPoster.innerHTML = '';
|
osdPoster.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
let osdLockCount = 0;
|
let mouseIsDown = false;
|
||||||
|
|
||||||
function showOsd() {
|
function showOsd() {
|
||||||
slideDownToShow(headerElement);
|
slideDownToShow(headerElement);
|
||||||
showMainOsdControls();
|
showMainOsdControls();
|
||||||
if (!osdLockCount) {
|
resetIdle();
|
||||||
startOsdHideTimer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideOsd() {
|
function hideOsd() {
|
||||||
if (osdLockCount) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
slideUpToHide(headerElement);
|
slideUpToHide(headerElement);
|
||||||
hideMainOsdControls();
|
hideMainOsdControls();
|
||||||
}
|
}
|
||||||
|
@ -381,19 +379,6 @@ import 'css!assets/css/videoosd';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function lockOsd() {
|
|
||||||
osdLockCount++;
|
|
||||||
stopOsdHideTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
function unlockOsd() {
|
|
||||||
osdLockCount--;
|
|
||||||
// Restart hide timer if OSD is currently visible
|
|
||||||
if (currentVisibleMenu && !osdLockCount) {
|
|
||||||
startOsdHideTimer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function startOsdHideTimer() {
|
function startOsdHideTimer() {
|
||||||
stopOsdHideTimer();
|
stopOsdHideTimer();
|
||||||
osdHideTimeout = setTimeout(hideOsd, 3e3);
|
osdHideTimeout = setTimeout(hideOsd, 3e3);
|
||||||
|
@ -465,6 +450,17 @@ import 'css!assets/css/videoosd';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move all idle-related code to `inputManager` or `idleManager` or `idleHelper` (per dialog thing) and listen event from there.
|
||||||
|
|
||||||
|
function resetIdle() {
|
||||||
|
// Restart hide timer if OSD is currently visible and there is no opened dialog
|
||||||
|
if (currentVisibleMenu && !mouseIsDown && !getOpenedDialog()) {
|
||||||
|
startOsdHideTimer();
|
||||||
|
} else {
|
||||||
|
stopOsdHideTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onPointerMove(e) {
|
function onPointerMove(e) {
|
||||||
if ('mouse' === (e.pointerType || (layoutManager.mobile ? 'touch' : 'mouse'))) {
|
if ('mouse' === (e.pointerType || (layoutManager.mobile ? 'touch' : 'mouse'))) {
|
||||||
const eventX = e.screenX || 0;
|
const eventX = e.screenX || 0;
|
||||||
|
@ -981,7 +977,11 @@ import 'css!assets/css/videoosd';
|
||||||
stats: true,
|
stats: true,
|
||||||
suboffset: showSubOffset,
|
suboffset: showSubOffset,
|
||||||
onOption: onSettingsOption
|
onOption: onSettingsOption
|
||||||
|
}).finally(() => {
|
||||||
|
resetIdle();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(resetIdle, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1050,11 @@ import 'css!assets/css/videoosd';
|
||||||
if (index !== currentIndex) {
|
if (index !== currentIndex) {
|
||||||
playbackManager.setAudioStreamIndex(index, player);
|
playbackManager.setAudioStreamIndex(index, player);
|
||||||
}
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
resetIdle();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(resetIdle, 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,7 +1098,11 @@ import 'css!assets/css/videoosd';
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSubtitleSync();
|
toggleSubtitleSync();
|
||||||
|
}).finally(() => {
|
||||||
|
resetIdle();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(resetIdle, 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1123,7 +1131,7 @@ import 'css!assets/css/videoosd';
|
||||||
let clickedElement;
|
let clickedElement;
|
||||||
|
|
||||||
function onKeyDown(e) {
|
function onKeyDown(e) {
|
||||||
clickedElement = e.srcElement;
|
clickedElement = e.target;
|
||||||
|
|
||||||
const key = keyboardnavigation.getKeyName(e);
|
const key = keyboardnavigation.getKeyName(e);
|
||||||
|
|
||||||
|
@ -1145,7 +1153,7 @@ import 'css!assets/css/videoosd';
|
||||||
case 'Escape':
|
case 'Escape':
|
||||||
case 'Back':
|
case 'Back':
|
||||||
// Ignore key when some dialog is opened
|
// Ignore key when some dialog is opened
|
||||||
if (currentVisibleMenu === 'osd' && !document.querySelector('.dialogContainer')) {
|
if (currentVisibleMenu === 'osd' && !getOpenedDialog()) {
|
||||||
hideOsd();
|
hideOsd();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
@ -1238,28 +1246,35 @@ import 'css!assets/css/videoosd';
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyDownCapture() {
|
function onKeyDownCapture() {
|
||||||
// Restart hide timer if OSD is currently visible
|
resetIdle();
|
||||||
if (currentVisibleMenu) {
|
|
||||||
showOsd();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWindowMouseDown(e) {
|
function onWindowMouseDown(e) {
|
||||||
clickedElement = e.srcElement;
|
clickedElement = e.target;
|
||||||
lockOsd();
|
mouseIsDown = true;
|
||||||
|
resetIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWindowMouseUp() {
|
function onWindowMouseUp() {
|
||||||
unlockOsd();
|
mouseIsDown = false;
|
||||||
|
resetIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWindowTouchStart(e) {
|
function onWindowTouchStart(e) {
|
||||||
clickedElement = e.srcElement;
|
clickedElement = e.target;
|
||||||
lockOsd();
|
mouseIsDown = true;
|
||||||
|
resetIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWindowTouchEnd() {
|
function onWindowTouchEnd() {
|
||||||
unlockOsd();
|
mouseIsDown = false;
|
||||||
|
resetIdle();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onWindowDragEnd() {
|
||||||
|
// mousedown -> dragstart -> dragend !!! no mouseup :(
|
||||||
|
mouseIsDown = false;
|
||||||
|
resetIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImgUrl(item, chapter, index, maxWidth, apiClient) {
|
function getImgUrl(item, chapter, index, maxWidth, apiClient) {
|
||||||
|
@ -1395,24 +1410,33 @@ import 'css!assets/css/videoosd';
|
||||||
inputManager.on(window, onInputCommand);
|
inputManager.on(window, onInputCommand);
|
||||||
document.addEventListener('keydown', onKeyDown);
|
document.addEventListener('keydown', onKeyDown);
|
||||||
dom.addEventListener(document, 'keydown', onKeyDownCapture, {
|
dom.addEventListener(document, 'keydown', onKeyDownCapture, {
|
||||||
capture: true
|
capture: true,
|
||||||
|
passive: true
|
||||||
});
|
});
|
||||||
/* eslint-disable-next-line compat/compat */
|
/* eslint-disable-next-line compat/compat */
|
||||||
dom.addEventListener(window, window.PointerEvent ? 'pointerdown' : 'mousedown', onWindowMouseDown, {
|
dom.addEventListener(window, window.PointerEvent ? 'pointerdown' : 'mousedown', onWindowMouseDown, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
/* eslint-disable-next-line compat/compat */
|
/* eslint-disable-next-line compat/compat */
|
||||||
dom.addEventListener(window, window.PointerEvent ? 'pointerup' : 'mouseup', onWindowMouseUp, {
|
dom.addEventListener(window, window.PointerEvent ? 'pointerup' : 'mouseup', onWindowMouseUp, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
dom.addEventListener(window, 'touchstart', onWindowTouchStart, {
|
dom.addEventListener(window, 'touchstart', onWindowTouchStart, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
['touchend', 'touchcancel'].forEach((event) => {
|
['touchend', 'touchcancel'].forEach((event) => {
|
||||||
dom.addEventListener(window, event, onWindowTouchEnd, {
|
dom.addEventListener(window, event, onWindowTouchEnd, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
dom.addEventListener(window, 'dragend', onWindowDragEnd, {
|
||||||
|
capture: true,
|
||||||
|
passive: true
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
import('appRouter').then(({default: appRouter}) => {
|
import('appRouter').then(({default: appRouter}) => {
|
||||||
appRouter.goHome();
|
appRouter.goHome();
|
||||||
|
@ -1426,24 +1450,33 @@ import 'css!assets/css/videoosd';
|
||||||
|
|
||||||
document.removeEventListener('keydown', onKeyDown);
|
document.removeEventListener('keydown', onKeyDown);
|
||||||
dom.removeEventListener(document, 'keydown', onKeyDownCapture, {
|
dom.removeEventListener(document, 'keydown', onKeyDownCapture, {
|
||||||
capture: true
|
capture: true,
|
||||||
|
passive: true
|
||||||
});
|
});
|
||||||
/* eslint-disable-next-line compat/compat */
|
/* eslint-disable-next-line compat/compat */
|
||||||
dom.removeEventListener(window, window.PointerEvent ? 'pointerdown' : 'mousedown', onWindowMouseDown, {
|
dom.removeEventListener(window, window.PointerEvent ? 'pointerdown' : 'mousedown', onWindowMouseDown, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
/* eslint-disable-next-line compat/compat */
|
/* eslint-disable-next-line compat/compat */
|
||||||
dom.removeEventListener(window, window.PointerEvent ? 'pointerup' : 'mouseup', onWindowMouseUp, {
|
dom.removeEventListener(window, window.PointerEvent ? 'pointerup' : 'mouseup', onWindowMouseUp, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
dom.removeEventListener(window, 'touchstart', onWindowTouchStart, {
|
dom.removeEventListener(window, 'touchstart', onWindowTouchStart, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
['touchend', 'touchcancel'].forEach((event) => {
|
['touchend', 'touchcancel'].forEach((event) => {
|
||||||
dom.removeEventListener(window, event, onWindowTouchEnd, {
|
dom.removeEventListener(window, event, onWindowTouchEnd, {
|
||||||
|
capture: true,
|
||||||
passive: true
|
passive: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
dom.removeEventListener(window, 'dragend', onWindowDragEnd, {
|
||||||
|
capture: true,
|
||||||
|
passive: true
|
||||||
|
});
|
||||||
stopOsdHideTimer();
|
stopOsdHideTimer();
|
||||||
headerElement.classList.remove('osdHeader');
|
headerElement.classList.remove('osdHeader');
|
||||||
headerElement.classList.remove('osdHeader-hidden');
|
headerElement.classList.remove('osdHeader-hidden');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue