mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 02:22:09 +00:00
feat: Stream - Add StreamItemState field
feat: Player - new StreamStateChanged action for player Signed-off-by: Lachezar Lechev <lachezar@ambire.com>
This commit is contained in:
parent
5dc088b798
commit
74c925ecb1
4 changed files with 62 additions and 1 deletions
1
src/routes/Player/usePlayer.d.ts
vendored
1
src/routes/Player/usePlayer.d.ts
vendored
|
|
@ -6,6 +6,7 @@ declare const usePlayer: (urlParams: UrlParams) => [
|
|||
pausedChanged: (paused: boolean) => void, () => void, () => void,
|
||||
ended: () => void,
|
||||
nextVideo: () => void,
|
||||
streamStateChanged: (state: StreamItemState ) => void,
|
||||
];
|
||||
|
||||
export = usePlayer;
|
||||
|
|
|
|||
|
|
@ -153,8 +153,18 @@ const usePlayer = (urlParams) => {
|
|||
}, 'player');
|
||||
}, []);
|
||||
|
||||
const streamStateChanged = React.useCallback((streamStateChanged) => {
|
||||
core.transport.dispatch({
|
||||
action: 'Player',
|
||||
args: {
|
||||
action: 'StreamStateChanged',
|
||||
args: { state: streamStateChanged }
|
||||
}
|
||||
}, 'player');
|
||||
}, []);
|
||||
|
||||
const player = useModelState({ model: 'player', action, map });
|
||||
return [player, videoParamsChanged, timeChanged, seek, pausedChanged, ended, nextVideo];
|
||||
return [player, videoParamsChanged, timeChanged, seek, pausedChanged, ended, nextVideo, streamStateChanged];
|
||||
};
|
||||
|
||||
module.exports = usePlayer;
|
||||
|
|
|
|||
49
src/types/Stream.d.ts
vendored
49
src/types/Stream.d.ts
vendored
|
|
@ -16,3 +16,52 @@ type Stream = {
|
|||
externalPlayer: ExternalPlayerLinks,
|
||||
},
|
||||
};
|
||||
|
||||
type StreamItemState = {
|
||||
subtitleTrack?: StreamSubtitleTrack;
|
||||
/**
|
||||
* In milliseconds
|
||||
*/
|
||||
subtitleDelay?: number;
|
||||
/**
|
||||
* Subtitles size, platform-dependent units
|
||||
*/
|
||||
subtitleSize?: number;
|
||||
/**
|
||||
* Vertical offset of the subtitles, platform-dependent units
|
||||
*/
|
||||
subtitleOffset?: number;
|
||||
audioTrack?: StreamAudioTrack;
|
||||
/**
|
||||
* In milliseconds
|
||||
*/
|
||||
audioDelay?: number;
|
||||
playbackSpeed?: number;
|
||||
playerType?: string;
|
||||
};
|
||||
|
||||
type StreamSubtitleTrack = {
|
||||
/**
|
||||
* Id of the subtitle track
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Flag indicating whether this is an embedded subtitle or an addon subtitle
|
||||
*/
|
||||
embedded: boolean;
|
||||
/**
|
||||
* Optional string indicating subtitle language
|
||||
*/
|
||||
language?: string;
|
||||
};
|
||||
|
||||
type StreamAudioTrack = {
|
||||
/**
|
||||
* Id of the audio track
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Optional string indicating audio language
|
||||
*/
|
||||
language?: string;
|
||||
};
|
||||
|
|
|
|||
1
src/types/models/Player.d.ts
vendored
1
src/types/models/Player.d.ts
vendored
|
|
@ -41,6 +41,7 @@ type Player = {
|
|||
streamRequest: ResourceRequest,
|
||||
subtitlesPath: ResourceRequestPath,
|
||||
} | null,
|
||||
stream_state: StreamItemState | null,
|
||||
seriesInfo: SeriesInfo | null,
|
||||
subtitles: Subtitle[],
|
||||
title: string | null,
|
||||
|
|
|
|||
Loading…
Reference in a new issue