mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 14:52:13 +00:00
Merge pull request #336 from Stremio/video-params-for-subs
Add Video Params for Subs Requests
This commit is contained in:
commit
1447b6ce20
2 changed files with 36 additions and 34 deletions
|
|
@ -30,7 +30,39 @@ const Player = ({ urlParams, queryParams }) => {
|
|||
queryParams.has('maxAudioChannels') ? parseInt(queryParams.get('maxAudioChannels'), 10) : null
|
||||
];
|
||||
}, [queryParams]);
|
||||
const [player, timeChanged, pausedChanged, ended, pushToLibrary] = usePlayer(urlParams);
|
||||
const [videoState, setVideoState] = React.useReducer(
|
||||
(videoState, nextVideoState) => ({ ...videoState, ...nextVideoState }),
|
||||
{
|
||||
manifest: null,
|
||||
stream: null,
|
||||
paused: null,
|
||||
time: null,
|
||||
duration: null,
|
||||
buffering: null,
|
||||
volume: null,
|
||||
muted: null,
|
||||
playbackSpeed: null,
|
||||
videoParams: null,
|
||||
audioTracks: [],
|
||||
selectedAudioTrackId: null,
|
||||
subtitlesTracks: [],
|
||||
selectedSubtitlesTrackId: null,
|
||||
subtitlesOffset: null,
|
||||
subtitlesSize: null,
|
||||
subtitlesTextColor: null,
|
||||
subtitlesBackgroundColor: null,
|
||||
subtitlesOutlineColor: null,
|
||||
extraSubtitlesTracks: [],
|
||||
selectedExtraSubtitlesTrackId: null,
|
||||
extraSubtitlesSize: null,
|
||||
extraSubtitlesDelay: null,
|
||||
extraSubtitlesOffset: null,
|
||||
extraSubtitlesTextColor: null,
|
||||
extraSubtitlesBackgroundColor: null,
|
||||
extraSubtitlesOutlineColor: null
|
||||
}
|
||||
);
|
||||
const [player, timeChanged, pausedChanged, ended, pushToLibrary] = usePlayer(urlParams, videoState.videoParams);
|
||||
const [settings, updateSettings] = useSettings();
|
||||
const streamingServer = useStreamingServer();
|
||||
const routeFocused = useRouteFocused();
|
||||
|
|
@ -51,37 +83,6 @@ const Player = ({ urlParams, queryParams }) => {
|
|||
const defaultSubtitlesSelected = React.useRef(false);
|
||||
const defaultAudioTrackSelected = React.useRef(false);
|
||||
const [error, setError] = React.useState(null);
|
||||
const [videoState, setVideoState] = React.useReducer(
|
||||
(videoState, nextVideoState) => ({ ...videoState, ...nextVideoState }),
|
||||
{
|
||||
manifest: null,
|
||||
stream: null,
|
||||
paused: null,
|
||||
time: null,
|
||||
duration: null,
|
||||
buffering: null,
|
||||
volume: null,
|
||||
muted: null,
|
||||
playbackSpeed: null,
|
||||
audioTracks: [],
|
||||
selectedAudioTrackId: null,
|
||||
subtitlesTracks: [],
|
||||
selectedSubtitlesTrackId: null,
|
||||
subtitlesOffset: null,
|
||||
subtitlesSize: null,
|
||||
subtitlesTextColor: null,
|
||||
subtitlesBackgroundColor: null,
|
||||
subtitlesOutlineColor: null,
|
||||
extraSubtitlesTracks: [],
|
||||
selectedExtraSubtitlesTrackId: null,
|
||||
extraSubtitlesSize: null,
|
||||
extraSubtitlesDelay: null,
|
||||
extraSubtitlesOffset: null,
|
||||
extraSubtitlesTextColor: null,
|
||||
extraSubtitlesBackgroundColor: null,
|
||||
extraSubtitlesOutlineColor: null
|
||||
}
|
||||
);
|
||||
const videoRef = React.useRef(null);
|
||||
const dispatch = React.useCallback((action, options) => {
|
||||
if (videoRef.current !== null) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const map = (player) => ({
|
|||
player.metaItem,
|
||||
});
|
||||
|
||||
const usePlayer = (urlParams) => {
|
||||
const usePlayer = (urlParams, videoParams) => {
|
||||
const { core } = useServices();
|
||||
const { decodeStream } = useCoreSuspender();
|
||||
const stream = decodeStream(urlParams.stream);
|
||||
|
|
@ -44,6 +44,7 @@ const usePlayer = (urlParams) => {
|
|||
model: 'Player',
|
||||
args: {
|
||||
stream,
|
||||
videoParams,
|
||||
streamRequest: typeof urlParams.streamTransportUrl === 'string' && typeof urlParams.type === 'string' && typeof urlParams.videoId === 'string' ?
|
||||
{
|
||||
base: urlParams.streamTransportUrl,
|
||||
|
|
@ -85,7 +86,7 @@ const usePlayer = (urlParams) => {
|
|||
action: 'Unload'
|
||||
};
|
||||
}
|
||||
}, [urlParams]);
|
||||
}, [urlParams, videoParams]);
|
||||
const timeChanged = React.useCallback((time, duration, device) => {
|
||||
core.transport.dispatch({
|
||||
action: 'Player',
|
||||
|
|
|
|||
Loading…
Reference in a new issue