Skip to content

Commit

Permalink
hotfix for video params
Browse files Browse the repository at this point in the history
  • Loading branch information
unclekingpin committed Oct 22, 2023
1 parent 9c85105 commit 0f5a0c0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/routes/Player/usePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const map = (player) => ({
player.metaItem,
});

const usePlayer = (urlParams, videoParams) => {
const usePlayer = (urlParams) => {
const { core } = useServices();
const { decodeStream } = useCoreSuspender();
const stream = decodeStream(urlParams.stream);
Expand All @@ -44,7 +44,6 @@ const usePlayer = (urlParams, videoParams) => {
model: 'Player',
args: {
stream,
videoParams,
streamRequest: typeof urlParams.streamTransportUrl === 'string' && typeof urlParams.type === 'string' && typeof urlParams.videoId === 'string' ?
{
base: urlParams.streamTransportUrl,
Expand Down Expand Up @@ -86,7 +85,16 @@ const usePlayer = (urlParams, videoParams) => {
action: 'Unload'
};
}
}, [urlParams, videoParams]);
}, [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',
Expand Down Expand Up @@ -114,6 +122,10 @@ const usePlayer = (urlParams, videoParams) => {
}, 'player');
}, []);
const player = useModelState({ model: 'player', action, map });
// Hotfix for compatability between latest stremio-core and current stremio-web
React.useInsertionEffect(() => {
videoParamsChanged({});
}, [action]);
return [player, timeChanged, pausedChanged, ended];
};

Expand Down

0 comments on commit 0f5a0c0

Please sign in to comment.