Skip to content

Commit

Permalink
chore(typescript): fix external loaded textTracks typing and add one …
Browse files Browse the repository at this point in the history
…in sample (#3626)
  • Loading branch information
freeboub authored Mar 30, 2024
1 parent dd3a400 commit 182c953
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
16 changes: 15 additions & 1 deletion examples/basic/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import Video, {
SelectedTrack,
DRMType,
OnTextTrackDataChangedData,
SelectedTrackType,
TextTrackType,
ISO639_1,
} from 'react-native-video';
import ToggleControl from './ToggleControl';
import MultiValueControl, {
Expand Down Expand Up @@ -127,6 +128,18 @@ class VideoPlayer extends Component {
description: 'sintel with subtitles',
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 = [];
Expand Down Expand Up @@ -762,6 +775,7 @@ class VideoPlayer extends Component {
this.video = ref;
}}
source={this.srcList[this.state.srcListId]}
textTracks={this.srcList[this.state.srcListId]?.textTracks}
adTagUrl={this.srcList[this.state.srcListId]?.adTagUrl}
drm={this.srcList[this.state.srcListId]?.drm}
style={viewStyle}
Expand Down
2 changes: 1 addition & 1 deletion src/types/TextTrackType.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enum TextTrackType {
SRT = 'application/x-subrip',
SUBRIP = 'application/x-subrip',
TTML = 'application/ttml+xml',
VTT = 'text/vtt',
}
Expand Down
12 changes: 6 additions & 6 deletions src/types/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export type SubtitleStyle = {
opacity?: number;
};

export enum TextTracksType {
export enum TextTrackType {
SUBRIP = 'application/x-subrip',
TTML = 'application/ttml+xml',
VTT = 'text/vtt',
Expand All @@ -117,31 +117,31 @@ export enum TextTracksType {
export type TextTracks = {
title: string;
language: ISO639_1;
type: TextTracksType;
type: TextTrackType;
uri: string;
}[];

export type TextTrackType =
export type TextTrackSelectionType =
| 'system'
| 'disabled'
| 'title'
| 'language'
| 'index';

export type SelectedTextTrack = Readonly<{
type: TextTrackType;
type: TextTrackSelectionType;
value?: string | number;
}>;

export type AudioTrackType =
export type AudioTrackSelectionType =
| 'system'
| 'disabled'
| 'title'
| 'language'
| 'index';

export type SelectedAudioTrack = Readonly<{
type: AudioTrackType;
type: AudioTrackSelectionType;
value?: string | number;
}>;

Expand Down

0 comments on commit 182c953

Please sign in to comment.