Skip to content

Commit

Permalink
feat: temporary commit - reusing enum types for remaining docs types
Browse files Browse the repository at this point in the history
  • Loading branch information
yungblud committed Jan 30, 2024
1 parent e69666d commit d1a858a
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 26 deletions.
64 changes: 45 additions & 19 deletions src/specs/VideoNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type VideoSrc = Readonly<{
customImageUri?: string;
}>;

export type DRMType = WithDefault<
type DRMType = WithDefault<
'widevine' | 'playready' | 'clearkey' | 'fairplay',
'widevine'
>;
Expand Down Expand Up @@ -67,16 +67,36 @@ type TextTracks = ReadonlyArray<
}>
>;

type SelectedTrack = WithDefault<
type SelectedTextTrackType = WithDefault<
'system' | 'disabled' | 'title' | 'language' | 'index',
'system'
>;

export type SelectedTrackType = Readonly<{
type?: SelectedTrack;
type SelectedAudioTrackType = WithDefault<
'system' | 'disabled' | 'title' | 'language' | 'index',
'system'
>;

type SelectedTextTrack = Readonly<{
type?: SelectedTextTrackType;
value?: string;
}>;

type SelectedAudioTrack = Readonly<{
type?: SelectedAudioTrackType;
value?: string;
}>;

type SelectedVideoTrackType = WithDefault<
'auto' | 'disabled' | 'resolution' | 'index',
'auto'
>;

type SelectedVideoTrack = Readonly<{
type?: SelectedVideoTrackType;
value?: Int32;
}>;

export type Seek = Readonly<{
time: Float;
tolerance?: Float;
Expand All @@ -92,16 +112,6 @@ type BufferConfig = Readonly<{
minBufferMemoryReservePercent?: Float;
}>;

type SelectedVideoTrack = WithDefault<
'auto' | 'disabled' | 'resolution' | 'index',
'auto'
>;

export type SelectedVideoTrackType = Readonly<{
type?: SelectedVideoTrack;
value?: Int32;
}>;

type SubtitleStyle = Readonly<{
fontSize?: Float;
paddingTop?: WithDefault<Float, 0>;
Expand All @@ -118,8 +128,24 @@ export type OnLoadData = Readonly<{
height: Float;
orientation: WithDefault<'landscape' | 'portrait', 'landscape'>;
}>;
audioTracks: Readonly<{}>;
textTracks: Readonly<{}>;
audioTracks: {
index: Int32;
title?: string;
language?: string;
bitrate?: Float;
type?: string;
selected?: boolean;
}[];
textTracks: {
index: Int32;
title?: string;
language?: string;
/**
* iOS only supports VTT, Android supports all 3
*/
type?: WithDefault<'srt' | 'ttml' | 'vtt', 'srt'>;
selected?: boolean;
}[];
}>;

export type OnLoadStartData = Readonly<{
Expand Down Expand Up @@ -409,8 +435,9 @@ export interface VideoNativeProps extends ViewProps {
repeat?: boolean;
automaticallyWaitsToMinimizeStalling?: boolean;
textTracks?: TextTracks;
selectedTextTrack?: SelectedTrackType;
selectedAudioTrack?: SelectedTrackType;
selectedTextTrack?: SelectedTextTrack;
selectedAudioTrack?: SelectedAudioTrack;
selectedVideoTrack?: SelectedVideoTrack; // android
paused?: boolean;
muted?: boolean;
controls?: boolean;
Expand Down Expand Up @@ -460,7 +487,6 @@ export interface VideoNativeProps extends ViewProps {
hideShutterView?: boolean; // Android
minLoadRetryCount?: Int32; // Android
reportBandwidth?: boolean; //Android
selectedVideoTrack?: SelectedVideoTrackType; // android
subtitleStyle?: SubtitleStyle; // android
trackId?: string; // Android
useTextureView?: boolean; // Android
Expand Down
3 changes: 3 additions & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import type {
OnVolumeChangeData,
} from '../specs/VideoNativeComponent';

export type AudioTrack = OnAudioTracksData['audioTracks'][number];
export type TextTrack = OnTextTracksData['textTracks'][number];

export interface ReactVideoEvents {
onAudioBecomingNoisy?: () => void; //Android, iOS
onAudioFocusChanged?: (e: OnAudioFocusChangedData) => void; // Android
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export {default as Orientation} from './Orientation';
export {default as ResizeMode} from './ResizeMode';
export {default as TextTrackType} from './TextTrackType';
export * from './video';
export * from '../specs/VideoNativeComponent';
35 changes: 28 additions & 7 deletions src/types/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import type {ReactVideoEvents} from './events';
import type {StyleProp, ViewProps, ViewStyle} from 'react-native';
import type VideoResizeMode from './ResizeMode';
import type FilterType from './FilterType';
import type {
SelectedTrackType,
SelectedVideoTrackType,
} from '../specs/VideoNativeComponent';

export type Headers = Record<string, string>;

Expand Down Expand Up @@ -74,6 +70,31 @@ export type BufferConfig = {
minBufferMemoryReservePercent?: number;
};

export enum SelectedTrackType {
SYSTEM = 'system',
DISABLED = 'disabled',
TITLE = 'title',
LANGUAGE = 'language',
INDEX = 'index',
}

export type SelectedTrack = {
type: SelectedTrackType;
value?: string;
};

export enum SelectedVideoTrackType {
AUTO = 'auto',
DISABLED = 'disabled',
RESOLUTION = 'resolution',
INDEX = 'index',
}

export type SelectedVideoTrack = {
type: SelectedVideoTrackType;
value?: number;
};

export type SubtitleStyle = {
fontSize?: number;
paddingTop?: number;
Expand Down Expand Up @@ -196,9 +217,9 @@ export interface ReactVideoProps extends ReactVideoEvents, ViewProps {
repeat?: boolean;
reportBandwidth?: boolean; //Android
resizeMode?: EnumValues<VideoResizeMode>;
selectedAudioTrack?: SelectedTrackType;
selectedTextTrack?: SelectedTrackType;
selectedVideoTrack?: SelectedVideoTrackType; // android
selectedAudioTrack?: SelectedTrack;
selectedTextTrack?: SelectedTrack;
selectedVideoTrack?: SelectedVideoTrack; // android
subtitleStyle?: SubtitleStyle; // android
textTracks?: TextTracks;
testID?: string;
Expand Down

0 comments on commit d1a858a

Please sign in to comment.