fix: update types (#3288)

This commit is contained in:
Krzysztof Moch 2023-10-11 22:15:58 +02:00 committed by GitHub
parent 7fd7b3ff32
commit 5c3baca1d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 23 deletions

View File

@ -59,6 +59,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
fullscreen, fullscreen,
drm, drm,
textTracks, textTracks,
selectedVideoTrack,
selectedAudioTrack, selectedAudioTrack,
selectedTextTrack, selectedTextTrack,
onLoadStart, onLoadStart,
@ -153,8 +154,9 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!drm) { if (!drm) {
return; return;
} }
return { return {
drmType: drm.type, type: drm.type,
licenseServer: drm.licenseServer, licenseServer: drm.licenseServer,
headers: drm.headers, headers: drm.headers,
contentId: drm.contentId, contentId: drm.contentId,
@ -168,14 +170,9 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!selectedTextTrack) { if (!selectedTextTrack) {
return; return;
} }
if (typeof selectedTextTrack?.value === 'number') {
return { return {
selectedTextType: selectedTextTrack?.type, type: selectedTextTrack?.type,
index: selectedTextTrack?.value,
};
}
return {
selectedTextType: selectedTextTrack?.type,
value: selectedTextTrack?.value, value: selectedTextTrack?.value,
}; };
}, [selectedTextTrack]); }, [selectedTextTrack]);
@ -184,18 +181,24 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (!selectedAudioTrack) { if (!selectedAudioTrack) {
return; return;
} }
if (typeof selectedAudioTrack?.value === 'number') {
return { return {
selectedAudioType: selectedAudioTrack?.type, type: selectedAudioTrack?.type,
index: selectedAudioTrack?.value,
};
}
return {
selectedAudioType: selectedAudioTrack?.type,
value: selectedAudioTrack?.value, value: selectedAudioTrack?.value,
}; };
}, [selectedAudioTrack]); }, [selectedAudioTrack]);
const _selectedVideoTrack = useMemo(() => {
if (!selectedVideoTrack) {
return;
}
return {
type: selectedVideoTrack?.type,
value: selectedVideoTrack?.value,
};
}, [selectedVideoTrack]);
const seek = useCallback(async (time: number, tolerance?: number) => { const seek = useCallback(async (time: number, tolerance?: number) => {
if (isNaN(time)) { if (isNaN(time)) {
throw new Error('Specified time is not a number'); throw new Error('Specified time is not a number');
@ -470,6 +473,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
textTracks={textTracks} textTracks={textTracks}
selectedTextTrack={_selectedTextTrack} selectedTextTrack={_selectedTextTrack}
selectedAudioTrack={_selectedAudioTrack} selectedAudioTrack={_selectedAudioTrack}
selectedVideoTrack={_selectedVideoTrack}
onGetLicense={onGetLicense} onGetLicense={onGetLicense}
onVideoLoad={onVideoLoad} onVideoLoad={onVideoLoad}
onVideoLoadStart={onVideoLoadStart} onVideoLoadStart={onVideoLoadStart}

View File

@ -53,7 +53,7 @@ type DebugConfig = Readonly<{
}>; }>;
type Drm = Readonly<{ type Drm = Readonly<{
drmType?: DrmType; type?: DrmType;
licenseServer?: string; licenseServer?: string;
headers?: Headers; headers?: Headers;
contentId?: string; // ios contentId?: string; // ios
@ -74,17 +74,15 @@ type TextTracks = ReadonlyArray<
type TextTrackType = 'system' | 'disabled' | 'title' | 'language' | 'index'; type TextTrackType = 'system' | 'disabled' | 'title' | 'language' | 'index';
type SelectedTextTrack = Readonly<{ type SelectedTextTrack = Readonly<{
selectedTextType: TextTrackType; type: TextTrackType;
value?: string; value?: string | number;
index?: number;
}>; }>;
type AudioTrackType = 'system' | 'disabled' | 'title' | 'language' | 'index'; type AudioTrackType = 'system' | 'disabled' | 'title' | 'language' | 'index';
type SelectedAudioTrack = Readonly<{ type SelectedAudioTrack = Readonly<{
selectedAudioType: AudioTrackType; type: AudioTrackType;
value?: string; value?: string | number;
index?: number;
}>; }>;
export type Seek = Readonly<{ export type Seek = Readonly<{
@ -146,7 +144,6 @@ export type OnBandwidthUpdateData = Readonly<{
export type OnSeekData = Readonly<{ export type OnSeekData = Readonly<{
currentTime: number; currentTime: number;
seekTime: number; seekTime: number;
finished: boolean;
}>; }>;
export type OnPlaybackStateChangedData = Readonly<{ export type OnPlaybackStateChangedData = Readonly<{