fix(android)!: rework video tracks management (#3778)

* fix: fix crash when invalid index type is provided and minor clean up
* fix: review video track management. Fix index support and rework string vs int in tracks management
* fix: ABR track selection check
* fix: split track selector in sample and lint code
* fix: ensure we don't report null fields
* chore: improve tracks displayed
* chore: start moving to selection by index only
This commit is contained in:
Olivier Bouillet
2024-05-22 14:01:55 +02:00
committed by GitHub
parent dbd7d7aa2c
commit cad5c4624c
15 changed files with 530 additions and 288 deletions

View File

@@ -222,13 +222,14 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!selectedVideoTrack) {
return;
}
const value = selectedVideoTrack?.value
? `${selectedVideoTrack.value}`
: undefined;
const type = typeof selectedVideoTrack.value;
if (type !== 'number' && type !== 'string') {
console.log('invalid type provided to selectedVideoTrack');
return;
}
return {
type: selectedVideoTrack?.type,
value,
value: `${selectedVideoTrack.value}`,
};
}, [selectedVideoTrack]);

View File

@@ -225,7 +225,8 @@ export type OnTextTrackDataChangedData = Readonly<{
export type OnVideoTracksData = Readonly<{
videoTracks: {
trackId: Int32;
index: Int32;
tracksId?: string;
codecs?: string;
width?: Float;
height?: Float;

View File

@@ -21,6 +21,7 @@ import type {
export type AudioTrack = OnAudioTracksData['audioTracks'][number];
export type TextTrack = OnTextTracksData['textTracks'][number];
export type VideoTrack = OnVideoTracksData['videoTracks'][number];
export type OnLoadData = Readonly<{
currentTime: number;
@@ -48,6 +49,15 @@ export type OnLoadData = Readonly<{
type?: WithDefault<'srt' | 'ttml' | 'vtt', 'srt'>;
selected?: boolean;
}[];
videoTracks: {
index: number;
tracksID?: string;
codecs?: string;
width?: number;
height?: number;
bitrate?: number;
selected?: boolean;
}[];
}>;
export type OnTextTracksData = Readonly<{

View File

@@ -117,7 +117,7 @@ export enum SelectedVideoTrackType {
export type SelectedVideoTrack = {
type: SelectedVideoTrackType;
value?: number;
value?: string | number;
};
export type SubtitleStyle = {