fix: avoid crash when setting index to 0 to tracks selection (#3721)
* fix(ts): onPlaybackRateChangeData was not correctly typed * fix: ensure tracks are well displayed in the sample * fix: avoid crash when setting invalid selected track or index 0
This commit is contained in:
parent
1a8295c8bf
commit
518a9a93e0
@ -193,13 +193,14 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
if (!selectedTextTrack) {
|
if (!selectedTextTrack) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const value = selectedTextTrack.value
|
const type = typeof selectedTextTrack.value;
|
||||||
? `${selectedTextTrack.value}`
|
if (type !== 'number' && type !== 'string') {
|
||||||
: undefined;
|
console.log('invalid type provided to selectedTextTrack');
|
||||||
|
return;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
type: selectedTextTrack?.type,
|
type: selectedTextTrack?.type,
|
||||||
value,
|
value: `${selectedTextTrack.value}`,
|
||||||
};
|
};
|
||||||
}, [selectedTextTrack]);
|
}, [selectedTextTrack]);
|
||||||
|
|
||||||
@ -207,13 +208,15 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
if (!selectedAudioTrack) {
|
if (!selectedAudioTrack) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const value = selectedAudioTrack.value
|
const type = typeof selectedAudioTrack.value;
|
||||||
? `${selectedAudioTrack.value}`
|
if (type !== 'number' && type !== 'string') {
|
||||||
: undefined;
|
console.log('invalid type provided to selectedAudioTrack');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: selectedAudioTrack?.type,
|
type: selectedAudioTrack?.type,
|
||||||
value,
|
value: `${selectedAudioTrack.value}`,
|
||||||
};
|
};
|
||||||
}, [selectedAudioTrack]);
|
}, [selectedAudioTrack]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user