mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-05 20:59:49 +00:00
Merge pull request #1120 from ArtificialSloth/fix/prevent-autoplay-when-using-external-player
Some checks are pending
Build / build (push) Waiting to run
Some checks are pending
Build / build (push) Waiting to run
Fix/Prevent autoplay when using an external player
This commit is contained in:
commit
7ab75cfc88
1 changed files with 7 additions and 1 deletions
|
|
@ -92,6 +92,7 @@ const Player = ({ urlParams, queryParams }) => {
|
|||
const defaultSubtitlesSelected = React.useRef(false);
|
||||
const subtitlesEnabled = React.useRef(true);
|
||||
const defaultAudioTrackSelected = React.useRef(false);
|
||||
const playingOnExternalDevice = React.useRef(false);
|
||||
const [error, setError] = React.useState(null);
|
||||
|
||||
const isNavigating = React.useRef(false);
|
||||
|
|
@ -196,6 +197,7 @@ const Player = ({ urlParams, queryParams }) => {
|
|||
}, []);
|
||||
|
||||
const onPlayRequested = React.useCallback(() => {
|
||||
playingOnExternalDevice.current = false;
|
||||
video.setPaused(false);
|
||||
setSeeking(false);
|
||||
}, []);
|
||||
|
|
@ -424,7 +426,9 @@ const Player = ({ urlParams, queryParams }) => {
|
|||
}, [video.state.time, video.state.duration, video.state.manifest, seeking]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (video.state.paused !== null) {
|
||||
if (playingOnExternalDevice.current && video.state.paused === false) {
|
||||
onPauseRequested();
|
||||
} else if (video.state.paused !== null) {
|
||||
pausedChanged(video.state.paused);
|
||||
}
|
||||
}, [video.state.paused]);
|
||||
|
|
@ -519,6 +523,7 @@ const Player = ({ urlParams, queryParams }) => {
|
|||
defaultSubtitlesSelected.current = false;
|
||||
defaultAudioTrackSelected.current = false;
|
||||
nextVideoPopupDismissed.current = false;
|
||||
playingOnExternalDevice.current = false;
|
||||
// we need a timeout here to make sure that previous page unloads and the new one loads
|
||||
// avoiding race conditions and flickering
|
||||
setTimeout(() => isNavigating.current = false, 1000);
|
||||
|
|
@ -560,6 +565,7 @@ const Player = ({ urlParams, queryParams }) => {
|
|||
};
|
||||
const onCoreEvent = ({ event }) => {
|
||||
if (event === 'PlayingOnDevice') {
|
||||
playingOnExternalDevice.current = true;
|
||||
onPauseRequested();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue