Merge pull request #1054 from Stremio/fix/player-next-video-behaviour

Player: next video behavior
This commit is contained in:
Timothy Z. 2025-11-27 18:25:47 +02:00 committed by GitHub
commit 199b00b290
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 14 deletions

View file

@ -8,7 +8,7 @@ const langs = require('langs');
const { useTranslation } = require('react-i18next'); const { useTranslation } = require('react-i18next');
const { useRouteFocused } = require('stremio-router'); const { useRouteFocused } = require('stremio-router');
const { useServices } = require('stremio/services'); 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 { HorizontalNavBar, Transition, ContextMenu } = require('stremio/components');
const BufferingLoader = require('./BufferingLoader'); const BufferingLoader = require('./BufferingLoader');
const VolumeChangeIndicator = require('./VolumeChangeIndicator'); const VolumeChangeIndicator = require('./VolumeChangeIndicator');
@ -36,7 +36,7 @@ const Player = ({ urlParams, queryParams }) => {
const forceTranscoding = React.useMemo(() => { const forceTranscoding = React.useMemo(() => {
return queryParams.has('forceTranscoding'); return queryParams.has('forceTranscoding');
}, [queryParams]); }, [queryParams]);
const profile = useProfile();
const [player, videoParamsChanged, timeChanged, seek, pausedChanged, ended, nextVideo] = usePlayer(urlParams); const [player, videoParamsChanged, timeChanged, seek, pausedChanged, ended, nextVideo] = usePlayer(urlParams);
const [settings, updateSettings] = useSettings(); const [settings, updateSettings] = useSettings();
const streamingServer = useStreamingServer(); const streamingServer = useStreamingServer();
@ -105,13 +105,27 @@ 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) => { const handleNextVideoNavigation = React.useCallback((deepLinks, bingeWatching, ended) => {
if (deepLinks.player) { if (ended) {
isNavigating.current = true; if (bingeWatching) {
window.location.replace(deepLinks.player); if (deepLinks.player) {
} else if (deepLinks.metaDetailsStreams) { isNavigating.current = true;
isNavigating.current = true; window.location.replace(deepLinks.player);
window.location.replace(deepLinks.metaDetailsStreams); } else if (deepLinks.metaDetailsStreams) {
isNavigating.current = true;
window.location.replace(deepLinks.metaDetailsStreams);
}
} else {
window.history.back();
}
} 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 +141,8 @@ const Player = ({ urlParams, queryParams }) => {
nextVideo(); nextVideo();
const deepLinks = window.playerNextVideo.deepLinks; const deepLinks = window.playerNextVideo.deepLinks;
handleNextVideoNavigation(deepLinks); handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, true);
} else { } else {
window.history.back(); window.history.back();
} }
@ -257,9 +272,9 @@ const Player = ({ urlParams, queryParams }) => {
nextVideo(); nextVideo();
const deepLinks = player.nextVideo.deepLinks; 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(() => { const onVideoClick = React.useCallback(() => {
if (video.state.paused !== null) { if (video.state.paused !== null) {
@ -412,7 +427,7 @@ const Player = ({ urlParams, queryParams }) => {
}, [video.state.videoParams]); }, [video.state.videoParams]);
React.useEffect(() => { 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) { if (video.state.time !== null && video.state.duration !== null && video.state.time < video.state.duration && (video.state.duration - video.state.time) <= settings.nextVideoNotificationDuration) {
openNextVideoPopup(); openNextVideoPopup();
} else { } else {

View file

@ -111,7 +111,6 @@ const Player = forwardRef<HTMLDivElement, Props>(({ profile }: Props, ref) => {
<Option label={'SETTINGS_NEXT_VIDEO_POPUP_DURATION'}> <Option label={'SETTINGS_NEXT_VIDEO_POPUP_DURATION'}>
<MultiselectMenu <MultiselectMenu
className={'multiselect'} className={'multiselect'}
disabled={!profile.settings.bingeWatching}
{...nextVideoPopupDurationSelect} {...nextVideoPopupDurationSelect}
/> />
</Option> </Option>