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]);
const [player, timeChanged, pausedChanged, ended] = usePlayer(urlParams);
const [player, videoParamsChanged, timeChanged, pausedChanged, ended] = usePlayer(urlParams);
const [settings, updateSettings] = useSettings();
const streamingServer = useStreamingServer();
const routeFocused = useRouteFocused();
@ -68,6 +68,7 @@ const Player = ({ urlParams, queryParams }) => {
volume: null,
muted: null,
playbackSpeed: null,
videoParams: null,
audioTracks: [],
selectedAudioTrackId: null,
subtitlesTracks: [],
@ -352,6 +353,9 @@ const Player = ({ urlParams, queryParams }) => {
pausedChanged(videoState.paused);
}
}, [videoState.paused]);
React.useEffect(() => {
videoParamsChanged(videoState.videoParams);
}, [videoState.videoParams]);
React.useEffect(() => {
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) {

View file

@ -86,6 +86,15 @@ const usePlayer = (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) => {
core.transport.dispatch({
action: 'Player',
@ -113,7 +122,7 @@ const usePlayer = (urlParams) => {
}, 'player');
}, []);
const player = useModelState({ model: 'player', action, map });
return [player, timeChanged, pausedChanged, ended];
return [player, videoParamsChanged, timeChanged, pausedChanged, ended];
};
module.exports = usePlayer;