Merge pull request #787 from YouKnowBlom/player-pause-fix

Add delay on play/pause to prevent hiccup when entering/exiting fullscreen
This commit is contained in:
dkanada 2020-02-20 14:04:57 +09:00 committed by GitHub
commit b3fa02cbc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1218,12 +1218,14 @@ define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "med
return null;
}
let playPauseClickTimeout;
function onViewHideStopPlayback() {
if (playbackManager.isPlayingVideo()) {
require(['shell'], function (shell) {
shell.disableFullscreen();
});
clearTimeout(playPauseClickTimeout);
var player = currentPlayer;
view.removeEventListener("viewbeforehide", onViewHideStopPlayback);
releaseCurrentPlayer();
@ -1382,8 +1384,16 @@ define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "med
case "mouse":
if (!e.button) {
playbackManager.playPause(currentPlayer);
showOsd();
if (playPauseClickTimeout) {
clearTimeout(playPauseClickTimeout);
playPauseClickTimeout = 0;
} else {
playPauseClickTimeout = setTimeout(() => {
playbackManager.playPause(currentPlayer);
showOsd();
playPauseClickTimeout = 0;
}, 300);
}
}
break;