mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 15:52:02 +00:00
Merge pull request #914 from Stremio/fix/workaround-binge-watching-full-support
Some checks are pending
Build / build (push) Waiting to run
Some checks are pending
Build / build (push) Waiting to run
Shell: Fix binge watching flow
This commit is contained in:
commit
ec1e098c99
1 changed files with 19 additions and 3 deletions
|
|
@ -115,17 +115,22 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onEnded = React.useCallback(() => {
|
const onEnded = React.useCallback(() => {
|
||||||
|
// here we need to explicitly check for isNavigating.current
|
||||||
|
// the ended event can be called multiple times by MPV inside Shell
|
||||||
if (isNavigating.current) {
|
if (isNavigating.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ended();
|
ended();
|
||||||
if (player.nextVideo !== null) {
|
if (window.playerNextVideo !== null) {
|
||||||
onNextVideoRequested();
|
nextVideo();
|
||||||
|
|
||||||
|
const deepLinks = window.playerNextVideo.deepLinks;
|
||||||
|
handleNextVideoNavigation(deepLinks);
|
||||||
} else {
|
} else {
|
||||||
window.history.back();
|
window.history.back();
|
||||||
}
|
}
|
||||||
}, [player.nextVideo, onNextVideoRequested]);
|
}, []);
|
||||||
|
|
||||||
const onError = React.useCallback((error) => {
|
const onError = React.useCallback((error) => {
|
||||||
console.error('Player', error);
|
console.error('Player', error);
|
||||||
|
|
@ -405,6 +410,14 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
closeNextVideoPopup();
|
closeNextVideoPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (player.nextVideo) {
|
||||||
|
// This is a workaround for the fact that when we call onEnded nextVideo from the player is already set to null since core unloads the stream
|
||||||
|
// we explicitly set it to a global variable so we can access it in the onEnded function
|
||||||
|
// this is not a good solution but it works for now
|
||||||
|
window.playerNextVideo = player.nextVideo;
|
||||||
|
} else {
|
||||||
|
window.playerNextVideo = null;
|
||||||
|
}
|
||||||
}, [player.nextVideo, video.state.time, video.state.duration]);
|
}, [player.nextVideo, video.state.time, video.state.duration]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
@ -447,6 +460,9 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
defaultSubtitlesSelected.current = false;
|
defaultSubtitlesSelected.current = false;
|
||||||
defaultAudioTrackSelected.current = false;
|
defaultAudioTrackSelected.current = false;
|
||||||
nextVideoPopupDismissed.current = false;
|
nextVideoPopupDismissed.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);
|
||||||
}, [video.state.stream]);
|
}, [video.state.stream]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue