Merge pull request #1196 from Stremio/fix/space-bar-events-play-pause-handing
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
Timothy Z. 2026-04-16 12:27:02 +03:00 committed by GitHub
commit 5560813b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -636,17 +636,6 @@ const Player = ({ urlParams, queryParams }) => {
navigator.mediaSession.setActionHandler('nexttrack', nexVideoCallback);
}, [player.nextVideo, onPlayRequested, onPauseRequested, onNextVideoRequested]);
onShortcut('playPause', () => {
if (video.state.paused !== null) {
if (video.state.paused) {
onPlayRequested();
setSeeking(false);
} else if (!pressTimer.current) {
onPauseRequested();
}
}
}, [video.state.paused, pressTimer.current, onPlayRequested, onPauseRequested], !menusOpen);
onShortcut('seekForward', (combo) => {
if (video.state.time !== null) {
const seekDuration = combo === 1 ? settings.seekShortTimeDuration : settings.seekTimeDuration;
@ -791,7 +780,17 @@ const Player = ({ urlParams, queryParams }) => {
if (e.code === 'Space') {
clearTimeout(pressTimer.current);
pressTimer.current = null;
onPlaybackSpeedChanged(playbackSpeed.current);
if (longPress.current) {
onPlaybackSpeedChanged(playbackSpeed.current);
} else if (!menusOpen && video.state.paused !== null) {
if (video.state.paused) {
onPlayRequested();
setSeeking(false);
} else {
onPauseRequested();
}
}
longPress.current = false;
}
};
@ -844,7 +843,7 @@ const Player = ({ urlParams, queryParams }) => {
window.removeEventListener('mousedown', onMouseDownHold);
window.removeEventListener('mouseup', onMouseUp);
};
}, [routeFocused, menusOpen, video.state.volume]);
}, [routeFocused, menusOpen, video.state.volume, video.state.paused]);
React.useEffect(() => {
video.events.on('error', onError);