dispatch VideoParamsChanged action

This commit is contained in:
unclekingpin 2023-10-10 11:43:10 -07:00
parent 4300f5206d
commit cf74a57d46
2 changed files with 15 additions and 2 deletions

View file

@ -33,7 +33,7 @@ const Player = ({ urlParams, queryParams }) => {
queryParams.has('maxAudioChannels') ? parseInt(queryParams.get('maxAudioChannels'), 10) : null queryParams.has('maxAudioChannels') ? parseInt(queryParams.get('maxAudioChannels'), 10) : null
]; ];
}, [queryParams]); }, [queryParams]);
const [player, timeChanged, pausedChanged, ended] = usePlayer(urlParams); const [player, videoParamsChanged, timeChanged, pausedChanged, ended] = usePlayer(urlParams);
const [settings, updateSettings] = useSettings(); const [settings, updateSettings] = useSettings();
const streamingServer = useStreamingServer(); const streamingServer = useStreamingServer();
const routeFocused = useRouteFocused(); const routeFocused = useRouteFocused();
@ -68,6 +68,7 @@ const Player = ({ urlParams, queryParams }) => {
volume: null, volume: null,
muted: null, muted: null,
playbackSpeed: null, playbackSpeed: null,
videoParams: null,
audioTracks: [], audioTracks: [],
selectedAudioTrackId: null, selectedAudioTrackId: null,
subtitlesTracks: [], subtitlesTracks: [],
@ -352,6 +353,9 @@ const Player = ({ urlParams, queryParams }) => {
pausedChanged(videoState.paused); pausedChanged(videoState.paused);
} }
}, [videoState.paused]); }, [videoState.paused]);
React.useEffect(() => {
videoParamsChanged(videoState.videoParams);
}, [videoState.videoParams]);
React.useEffect(() => { React.useEffect(() => {
if (!!settings.bingeWatching && player.nextVideo !== null && !nextVideoPopupDismissed.current) { if (!!settings.bingeWatching && player.nextVideo !== null && !nextVideoPopupDismissed.current) {
if (videoState.time !== null && videoState.duration !== null && videoState.time < videoState.duration && (videoState.duration - videoState.time) <= settings.nextVideoNotificationDuration) { if (videoState.time !== null && videoState.duration !== null && videoState.time < videoState.duration && (videoState.duration - videoState.time) <= settings.nextVideoNotificationDuration) {

View file

@ -86,6 +86,15 @@ const usePlayer = (urlParams) => {
}; };
} }
}, [urlParams]); }, [urlParams]);
const videoParamsChanged = React.useCallback((videoParams) => {
core.transport.dispatch({
action: 'Player',
args: {
action: 'VideoParamsChanged',
args: { videoParams }
}
}, 'player');
}, []);
const timeChanged = React.useCallback((time, duration, device) => { const timeChanged = React.useCallback((time, duration, device) => {
core.transport.dispatch({ core.transport.dispatch({
action: 'Player', action: 'Player',
@ -113,7 +122,7 @@ const usePlayer = (urlParams) => {
}, 'player'); }, 'player');
}, []); }, []);
const player = useModelState({ model: 'player', action, map }); const player = useModelState({ model: 'player', action, map });
return [player, timeChanged, pausedChanged, ended]; return [player, videoParamsChanged, timeChanged, pausedChanged, ended];
}; };
module.exports = usePlayer; module.exports = usePlayer;