mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 03:22:11 +00:00
test(Player): fix binge watching (6)
This commit is contained in:
parent
9b405c53d8
commit
f446047f8b
1 changed files with 9 additions and 44 deletions
|
|
@ -85,6 +85,8 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
|
|
||||||
const nextVideoHandledRef = React.useRef(false);
|
const nextVideoHandledRef = React.useRef(false);
|
||||||
const nextVideoPopupDismissed = React.useRef(false);
|
const nextVideoPopupDismissed = React.useRef(false);
|
||||||
|
const nextVideoInitialData = React.useRef(player.nextVideo);
|
||||||
|
nextVideoInitialData.current = player.nextVideo;
|
||||||
const defaultSubtitlesSelected = React.useRef(false);
|
const defaultSubtitlesSelected = React.useRef(false);
|
||||||
const defaultAudioTrackSelected = React.useRef(false);
|
const defaultAudioTrackSelected = React.useRef(false);
|
||||||
const [error, setError] = React.useState(null);
|
const [error, setError] = React.useState(null);
|
||||||
|
|
@ -103,6 +105,7 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
}, [settings.subtitlesSize, settings.subtitlesOffset, settings.subtitlesTextColor, settings.subtitlesBackgroundColor, settings.subtitlesOutlineColor]);
|
}, [settings.subtitlesSize, settings.subtitlesOffset, settings.subtitlesTextColor, settings.subtitlesBackgroundColor, settings.subtitlesOutlineColor]);
|
||||||
|
|
||||||
const onEnded = React.useCallback(() => {
|
const onEnded = React.useCallback(() => {
|
||||||
|
player.nextVideo = nextVideoInitialData.current;
|
||||||
ended();
|
ended();
|
||||||
if (player.nextVideo !== null) {
|
if (player.nextVideo !== null) {
|
||||||
onNextVideoRequested();
|
onNextVideoRequested();
|
||||||
|
|
@ -216,35 +219,13 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
|
|
||||||
const onNextVideoRequested = React.useCallback(() => {
|
const onNextVideoRequested = React.useCallback(() => {
|
||||||
if (player.nextVideo !== null) {
|
if (player.nextVideo !== null) {
|
||||||
// Call nextVideo only for analytics
|
|
||||||
nextVideo();
|
nextVideo();
|
||||||
|
const deepLinks = player.nextVideo.deepLinks;
|
||||||
// Capture navigation data
|
if (deepLinks.metaDetailsStreams && deepLinks.player) {
|
||||||
const navigationLink = player.nextVideo.deepLinks.player ||
|
window.location.replace(deepLinks.metaDetailsStreams);
|
||||||
player.nextVideo.deepLinks.metaDetailsStreams;
|
window.location.href = deepLinks.player;
|
||||||
|
} else {
|
||||||
if (navigationLink) {
|
window.location.replace(deepLinks.player ?? deepLinks.metaDetailsStreams);
|
||||||
// Force immediate navigation with no chance of React re-renders affecting it
|
|
||||||
// This bypasses the React lifecycle entirely
|
|
||||||
const navigateImmediately = () => {
|
|
||||||
const form = document.createElement('form');
|
|
||||||
form.style.display = 'none';
|
|
||||||
form.method = 'GET';
|
|
||||||
form.action = navigationLink;
|
|
||||||
|
|
||||||
const input = document.createElement('input');
|
|
||||||
input.type = 'hidden';
|
|
||||||
input.name = 'navigationFromPlayer';
|
|
||||||
input.value = 'true';
|
|
||||||
form.appendChild(input);
|
|
||||||
|
|
||||||
// Force immediate navigation
|
|
||||||
document.body.appendChild(form);
|
|
||||||
form.submit();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Execute immediately
|
|
||||||
navigateImmediately();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [player.nextVideo]);
|
}, [player.nextVideo]);
|
||||||
|
|
@ -657,22 +638,6 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
|
||||||
// eslint-disable-next-line
|
|
||||||
const cameFromPlayer = urlParams.get('navigationFromPlayer');
|
|
||||||
|
|
||||||
if (cameFromPlayer === 'true') {
|
|
||||||
// eslint-disable-next-line
|
|
||||||
urlParams.delete('navigationFromPlayer');
|
|
||||||
const newUrl = window.location.pathname +
|
|
||||||
(urlParams.toString() ? '?' + urlParams.toString() : '') +
|
|
||||||
window.location.hash;
|
|
||||||
|
|
||||||
window.history.replaceState({}, '', newUrl);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classnames(styles['player-container'], { [styles['overlayHidden']]: overlayHidden })}
|
<div className={classnames(styles['player-container'], { [styles['overlayHidden']]: overlayHidden })}
|
||||||
onMouseDown={onContainerMouseDown}
|
onMouseDown={onContainerMouseDown}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue