fix(Player): binge watching in shell

This commit is contained in:
Timothy Z. 2025-05-02 19:42:49 +03:00
parent ce0c5da3fd
commit f3a7ef5978

View file

@ -88,6 +88,8 @@ const Player = ({ urlParams, queryParams }) => {
const defaultAudioTrackSelected = React.useRef(false); const defaultAudioTrackSelected = React.useRef(false);
const [error, setError] = React.useState(null); const [error, setError] = React.useState(null);
const isNavigating = React.useRef(false);
const onImplementationChanged = React.useCallback(() => { const onImplementationChanged = React.useCallback(() => {
video.setProp('subtitlesSize', settings.subtitlesSize); video.setProp('subtitlesSize', settings.subtitlesSize);
video.setProp('subtitlesOffset', settings.subtitlesOffset); video.setProp('subtitlesOffset', settings.subtitlesOffset);
@ -101,7 +103,24 @@ const Player = ({ urlParams, queryParams }) => {
video.setProp('extraSubtitlesOutlineColor', settings.subtitlesOutlineColor); video.setProp('extraSubtitlesOutlineColor', settings.subtitlesOutlineColor);
}, [settings.subtitlesSize, settings.subtitlesOffset, settings.subtitlesTextColor, settings.subtitlesBackgroundColor, settings.subtitlesOutlineColor]); }, [settings.subtitlesSize, settings.subtitlesOffset, settings.subtitlesTextColor, settings.subtitlesBackgroundColor, settings.subtitlesOutlineColor]);
const handleNextVideoNavigation = React.useCallback((deepLinks) => {
if (deepLinks.player) {
isNavigating.current = true;
window.location.href = deepLinks.player;
return true;
} else if (deepLinks.metaDetailsStreams) {
isNavigating.current = true;
window.location.href = deepLinks.metaDetailsStreams;
return true;
}
return false;
}, []);
const onEnded = React.useCallback(() => { const onEnded = React.useCallback(() => {
if (isNavigating.current) {
return;
}
ended(); ended();
if (player.nextVideo !== null) { if (player.nextVideo !== null) {
onNextVideoRequested(); onNextVideoRequested();
@ -218,14 +237,9 @@ const Player = ({ urlParams, queryParams }) => {
nextVideo(); nextVideo();
const deepLinks = player.nextVideo.deepLinks; const deepLinks = player.nextVideo.deepLinks;
if (deepLinks.metaDetailsStreams && deepLinks.player) { handleNextVideoNavigation(deepLinks);
window.location.replace(deepLinks.metaDetailsStreams);
window.location.href = deepLinks.player;
} else {
window.location.replace(deepLinks.player ?? deepLinks.metaDetailsStreams);
}
} }
}, [player.nextVideo]); }, [player.nextVideo, handleNextVideoNavigation]);
const onVideoClick = React.useCallback(() => { const onVideoClick = React.useCallback(() => {
if (video.state.paused !== null) { if (video.state.paused !== null) {