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:
Lachezar Lechev 2025-12-17 15:45:45 +02:00
parent 5dc088b798
commit 74c925ecb1
No known key found for this signature in database
GPG key ID: 69BDCB3ED8CE8037
4 changed files with 62 additions and 1 deletions

View file

@ -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;

View file

@ -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
View file

@ -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;
};

View file

@ -41,6 +41,7 @@ type Player = {
streamRequest: ResourceRequest,
subtitlesPath: ResourceRequestPath,
} | null,
stream_state: StreamItemState | null,
seriesInfo: SeriesInfo | null,
subtitles: Subtitle[],
title: string | null,