From 20c7ba672a0942393802f860eca27437efb9b02f Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Thu, 23 Oct 2025 10:05:35 +0300 Subject: [PATCH] fix: player - redirect to next video player deeplink only if bingeWatching is enabled, else go to stream list Signed-off-by: Lachezar Lechev --- src/routes/Player/Player.js | 55 +++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/src/routes/Player/Player.js b/src/routes/Player/Player.js index eab38bd96..4c8fbff99 100644 --- a/src/routes/Player/Player.js +++ b/src/routes/Player/Player.js @@ -8,7 +8,7 @@ const langs = require('langs'); const { useTranslation } = require('react-i18next'); const { useRouteFocused } = require('stremio-router'); const { useServices } = require('stremio/services'); -const { onFileDrop, useSettings, useFullscreen, useBinaryState, useToast, useStreamingServer, withCoreSuspender, CONSTANTS, useShell } = require('stremio/common'); +const { onFileDrop, useSettings, useProfile, useFullscreen, useBinaryState, useToast, useStreamingServer, withCoreSuspender, CONSTANTS, useShell } = require('stremio/common'); const { HorizontalNavBar, Transition, ContextMenu } = require('stremio/components'); const BufferingLoader = require('./BufferingLoader'); const VolumeChangeIndicator = require('./VolumeChangeIndicator'); @@ -36,7 +36,7 @@ const Player = ({ urlParams, queryParams }) => { const forceTranscoding = React.useMemo(() => { return queryParams.has('forceTranscoding'); }, [queryParams]); - + const profile = useProfile(); const [player, videoParamsChanged, timeChanged, seek, pausedChanged, ended, nextVideo] = usePlayer(urlParams); const [settings, updateSettings] = useSettings(); const streamingServer = useStreamingServer(); @@ -104,15 +104,22 @@ const Player = ({ urlParams, queryParams }) => { video.setProp('extraSubtitlesOutlineColor', 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.replace(deepLinks.player); - } else if (deepLinks.metaDetailsStreams) { - isNavigating.current = true; - window.location.replace(deepLinks.metaDetailsStreams); - } - }, []); + // const handleNextVideoNavigation = React.useCallback((deepLinks, bingeWatching, ended) => { + // if (bingeWatching && !ended) { + // if (deepLinks.player) { + // isNavigating.current = true; + // window.location.replace(deepLinks.player); + // } else if (deepLinks.metaDetailsStreams) { + // isNavigating.current = true; + // window.location.replace(deepLinks.metaDetailsStreams); + // } + // } else { + // if (!ended && deepLinks.metaDetailsStreams) { + // isNavigating.current = true; + // window.location.replace(deepLinks.metaDetailsStreams); + // } + // } + // }, []); const onEnded = React.useCallback(() => { // here we need to explicitly check for isNavigating.current @@ -126,7 +133,17 @@ const Player = ({ urlParams, queryParams }) => { nextVideo(); const deepLinks = window.playerNextVideo.deepLinks; - handleNextVideoNavigation(deepLinks); + // handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, true); + if (profile.settings.bingeWatching) { + if (deepLinks.player) { + isNavigating.current = true; + window.location.replace(deepLinks.player); + } else if (deepLinks.metaDetailsStreams) { + isNavigating.current = true; + window.location.replace(deepLinks.metaDetailsStreams); + } + } + } else { window.history.back(); } @@ -256,9 +273,17 @@ const Player = ({ urlParams, queryParams }) => { nextVideo(); const deepLinks = player.nextVideo.deepLinks; - handleNextVideoNavigation(deepLinks); + if (deepLinks.player) { + isNavigating.current = true; + window.location.replace(deepLinks.player); + } else if (deepLinks.metaDetailsStreams) { + isNavigating.current = true; + window.location.replace(deepLinks.metaDetailsStreams); + } + // handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, false); } - }, [player.nextVideo, handleNextVideoNavigation]); + // }, [player.nextVideo, handleNextVideoNavigation]); + }, [player.nextVideo, profile.settings]); const onVideoClick = React.useCallback(() => { if (video.state.paused !== null) { @@ -550,7 +575,7 @@ const Player = ({ urlParams, queryParams }) => { const videoId = player.selected ? player.selected.streamRequest.path.id : null; const video = metaItem ? metaItem.videos.find(({ id }) => id === videoId) : null; - const videoInfo = video && video.season && video.episode ? ` (${video.season}x${video.episode})`: null; + const videoInfo = video && video.season && video.episode ? ` (${video.season}x${video.episode})` : null; const videoTitle = video ? `${video.title}${videoInfo}` : null; const metaTitle = metaItem ? metaItem.name : null; const imageUrl = metaItem ? metaItem.logo : null;