chore(typescript): fix external loaded textTracks typing and add one in sample (#3626)

This commit is contained in:
Olivier Bouillet 2024-03-30 12:22:37 +01:00 committed by GitHub
parent dd3a400689
commit 182c953597
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 8 deletions

View File

@ -34,7 +34,8 @@ import Video, {
SelectedTrack, SelectedTrack,
DRMType, DRMType,
OnTextTrackDataChangedData, OnTextTrackDataChangedData,
SelectedTrackType, TextTrackType,
ISO639_1,
} from 'react-native-video'; } from 'react-native-video';
import ToggleControl from './ToggleControl'; import ToggleControl from './ToggleControl';
import MultiValueControl, { import MultiValueControl, {
@ -127,6 +128,18 @@ class VideoPlayer extends Component {
description: 'sintel with subtitles', description: 'sintel with subtitles',
uri: 'https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8', uri: 'https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
}, },
{
description: 'sintel with sideLoaded subtitles',
uri: 'https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8', // this is sample video, my actual video file is MP4
textTracks: [
{
title: 'test',
language: 'en' as ISO639_1,
type: TextTrackType.VTT,
uri: 'https://bitdash-a.akamaihd.net/content/sintel/subtitles/subtitles_en.vtt',
},
]
},
]; ];
srcIosList = []; srcIosList = [];
@ -762,6 +775,7 @@ class VideoPlayer extends Component {
this.video = ref; this.video = ref;
}} }}
source={this.srcList[this.state.srcListId]} source={this.srcList[this.state.srcListId]}
textTracks={this.srcList[this.state.srcListId]?.textTracks}
adTagUrl={this.srcList[this.state.srcListId]?.adTagUrl} adTagUrl={this.srcList[this.state.srcListId]?.adTagUrl}
drm={this.srcList[this.state.srcListId]?.drm} drm={this.srcList[this.state.srcListId]?.drm}
style={viewStyle} style={viewStyle}

View File

@ -1,5 +1,5 @@
enum TextTrackType { enum TextTrackType {
SRT = 'application/x-subrip', SUBRIP = 'application/x-subrip',
TTML = 'application/ttml+xml', TTML = 'application/ttml+xml',
VTT = 'text/vtt', VTT = 'text/vtt',
} }

View File

@ -108,7 +108,7 @@ export type SubtitleStyle = {
opacity?: number; opacity?: number;
}; };
export enum TextTracksType { export enum TextTrackType {
SUBRIP = 'application/x-subrip', SUBRIP = 'application/x-subrip',
TTML = 'application/ttml+xml', TTML = 'application/ttml+xml',
VTT = 'text/vtt', VTT = 'text/vtt',
@ -117,11 +117,11 @@ export enum TextTracksType {
export type TextTracks = { export type TextTracks = {
title: string; title: string;
language: ISO639_1; language: ISO639_1;
type: TextTracksType; type: TextTrackType;
uri: string; uri: string;
}[]; }[];
export type TextTrackType = export type TextTrackSelectionType =
| 'system' | 'system'
| 'disabled' | 'disabled'
| 'title' | 'title'
@ -129,11 +129,11 @@ export type TextTrackType =
| 'index'; | 'index';
export type SelectedTextTrack = Readonly<{ export type SelectedTextTrack = Readonly<{
type: TextTrackType; type: TextTrackSelectionType;
value?: string | number; value?: string | number;
}>; }>;
export type AudioTrackType = export type AudioTrackSelectionType =
| 'system' | 'system'
| 'disabled' | 'disabled'
| 'title' | 'title'
@ -141,7 +141,7 @@ export type AudioTrackType =
| 'index'; | 'index';
export type SelectedAudioTrack = Readonly<{ export type SelectedAudioTrack = Readonly<{
type: AudioTrackType; type: AudioTrackSelectionType;
value?: string | number; value?: string | number;
}>; }>;