diff --git a/package.json b/package.json index 284696840..c83c9c2cf 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@babel/runtime": "7.26.0", "@sentry/browser": "8.42.0", "@stremio/stremio-colors": "5.2.0", - "@stremio/stremio-core-web": "0.50.0", + "@stremio/stremio-core-web": "https://stremio.github.io/stremio-core/stremio-core-web/fix/player-next-video-behaviour/dev/stremio-stremio-core-web-0.50.0.tgz", "@stremio/stremio-icons": "5.7.1", "@stremio/stremio-video": "0.0.64", "a-color-picker": "1.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f0659a55..a1e7a8294 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,8 +18,8 @@ importers: specifier: 5.2.0 version: 5.2.0 '@stremio/stremio-core-web': - specifier: 0.50.0 - version: 0.50.0 + specifier: https://stremio.github.io/stremio-core/stremio-core-web/fix/player-next-video-behaviour/dev/stremio-stremio-core-web-0.50.0.tgz + version: https://stremio.github.io/stremio-core/stremio-core-web/fix/player-next-video-behaviour/dev/stremio-stremio-core-web-0.50.0.tgz '@stremio/stremio-icons': specifier: 5.7.1 version: 5.7.1 @@ -1302,8 +1302,9 @@ packages: '@stremio/stremio-colors@5.2.0': resolution: {integrity: sha512-dYlPgu9W/H7c9s1zmW5tiDnRenaUa4Hg1QCyOg1lhOcgSfM/bVTi5nnqX+IfvGTTUNA0zgzh8hI3o3miwnZxTg==} - '@stremio/stremio-core-web@0.50.0': - resolution: {integrity: sha512-SRE9nStgYNbhjJAw7mXfmM0wdnSLS4GMSJsSMTXvoGxnUgd+yisJUkN/9Sughe4t2IU7Uct8QWpdx9zFdlil+g==} + '@stremio/stremio-core-web@https://stremio.github.io/stremio-core/stremio-core-web/fix/player-next-video-behaviour/dev/stremio-stremio-core-web-0.50.0.tgz': + resolution: {tarball: https://stremio.github.io/stremio-core/stremio-core-web/fix/player-next-video-behaviour/dev/stremio-stremio-core-web-0.50.0.tgz} + version: 0.50.0 '@stremio/stremio-icons@5.7.1': resolution: {integrity: sha512-Z96p36LLX3G+ewMnFKmNZVsO/AtcHA33WQ3wGOYFubxiYADPRAkcLVU5rHIfiGSC9IUaUVhxQWTPVB9ScY4Q5Q==} @@ -6561,7 +6562,7 @@ snapshots: '@stremio/stremio-colors@5.2.0': {} - '@stremio/stremio-core-web@0.50.0': + '@stremio/stremio-core-web@https://stremio.github.io/stremio-core/stremio-core-web/fix/player-next-video-behaviour/dev/stremio-stremio-core-web-0.50.0.tgz': dependencies: '@babel/runtime': 7.24.1 diff --git a/src/routes/Player/Player.js b/src/routes/Player/Player.js index c0924bf7e..78fda087a 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, usePlatform } = require('stremio/common'); +const { onFileDrop, useSettings, useProfile, useFullscreen, useBinaryState, useToast, useStreamingServer, withCoreSuspender, CONSTANTS, useShell, usePlatform } = 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(); @@ -105,13 +105,25 @@ 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 (ended) { + 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 { + if (deepLinks.player) { + isNavigating.current = true; + window.location.replace(deepLinks.player); + } else if (deepLinks.metaDetailsStreams) { + isNavigating.current = true; + window.location.replace(deepLinks.metaDetailsStreams); + } } }, []); @@ -127,7 +139,8 @@ const Player = ({ urlParams, queryParams }) => { nextVideo(); const deepLinks = window.playerNextVideo.deepLinks; - handleNextVideoNavigation(deepLinks); + handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, true); + } else { window.history.back(); } @@ -257,9 +270,9 @@ const Player = ({ urlParams, queryParams }) => { nextVideo(); const deepLinks = player.nextVideo.deepLinks; - handleNextVideoNavigation(deepLinks); + handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, false); } - }, [player.nextVideo, handleNextVideoNavigation]); + }, [player.nextVideo, handleNextVideoNavigation, profile.settings]); const onVideoClick = React.useCallback(() => { if (video.state.paused !== null) { @@ -412,7 +425,7 @@ const Player = ({ urlParams, queryParams }) => { }, [video.state.videoParams]); React.useEffect(() => { - if (!!settings.bingeWatching && player.nextVideo !== null && !nextVideoPopupDismissed.current) { + if (player.nextVideo !== null && !nextVideoPopupDismissed.current) { if (video.state.time !== null && video.state.duration !== null && video.state.time < video.state.duration && (video.state.duration - video.state.time) <= settings.nextVideoNotificationDuration) { openNextVideoPopup(); } else { diff --git a/src/routes/Settings/Player/Player.tsx b/src/routes/Settings/Player/Player.tsx index 29b98d650..6c493d479 100644 --- a/src/routes/Settings/Player/Player.tsx +++ b/src/routes/Settings/Player/Player.tsx @@ -111,7 +111,6 @@ const Player = forwardRef(({ profile }: Props, ref) => {