mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 11:42:05 +00:00
Merge pull request #903 from Stremio/fix/binge-watching-bugs
Player(Shell): Fix binge watching bugs
This commit is contained in:
commit
252de8c496
1 changed files with 19 additions and 15 deletions
|
|
@ -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,21 @@ 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.replace(deepLinks.player);
|
||||||
|
} else if (deepLinks.metaDetailsStreams) {
|
||||||
|
isNavigating.current = true;
|
||||||
|
window.location.replace(deepLinks.metaDetailsStreams);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
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 +234,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) {
|
||||||
|
|
@ -620,14 +631,7 @@ const Player = ({ urlParams, queryParams }) => {
|
||||||
video.events.off('extraSubtitlesTrackAdded', onExtraSubtitlesTrackAdded);
|
video.events.off('extraSubtitlesTrackAdded', onExtraSubtitlesTrackAdded);
|
||||||
video.events.off('implementationChanged', onImplementationChanged);
|
video.events.off('implementationChanged', onImplementationChanged);
|
||||||
};
|
};
|
||||||
}, [
|
}, []);
|
||||||
onError,
|
|
||||||
onEnded,
|
|
||||||
onSubtitlesTrackLoaded,
|
|
||||||
onExtraSubtitlesTrackLoaded,
|
|
||||||
onExtraSubtitlesTrackAdded,
|
|
||||||
onImplementationChanged
|
|
||||||
]);
|
|
||||||
|
|
||||||
React.useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue