mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix error handling on some malformed videos
This commit is contained in:
parent
f798f2c025
commit
411bbef65c
@ -103,13 +103,18 @@ const Video = forwardRef<VideoRef, VideoProps>(function Video(
|
|||||||
onLoad?.(info);
|
onLoad?.(info);
|
||||||
}}
|
}}
|
||||||
onBuffer={onBuffer}
|
onBuffer={onBuffer}
|
||||||
onError={onMediaUnsupported}
|
onError={(error) => {
|
||||||
|
console.error(error);
|
||||||
|
if (mode === PlayMode.Direct) onMediaUnsupported?.();
|
||||||
|
else onError?.(error);
|
||||||
|
}}
|
||||||
selectedVideoTrack={
|
selectedVideoTrack={
|
||||||
video === -1
|
video === -1
|
||||||
? { type: SelectedVideoTrackType.AUDO }
|
? { type: SelectedVideoTrackType.AUDO }
|
||||||
: { type: SelectedVideoTrackType.RESOLUTION, value: video }
|
: { type: SelectedVideoTrackType.RESOLUTION, value: video }
|
||||||
}
|
}
|
||||||
selectedAudioTrack={{ type: SelectedTrackType.INDEX, value: audio.index }}
|
// when video file is invalid, audio is undefined
|
||||||
|
selectedAudioTrack={{ type: SelectedTrackType.INDEX, value: audio?.index ?? 0 }}
|
||||||
textTracks={subtitles?.map((x) => ({
|
textTracks={subtitles?.map((x) => ({
|
||||||
type: MimeTypes.get(x.codec) as any,
|
type: MimeTypes.get(x.codec) as any,
|
||||||
uri: x.link!,
|
uri: x.link!,
|
||||||
|
@ -182,7 +182,7 @@ const Video = forwardRef<{ seek: (value: number) => void }, VideoProps>(function
|
|||||||
if (!hls) return;
|
if (!hls) return;
|
||||||
const update = () => {
|
const update = () => {
|
||||||
if (!hls) return;
|
if (!hls) return;
|
||||||
hls.audioTrack = audio.index;
|
hls.audioTrack = audio?.index ?? 0;
|
||||||
};
|
};
|
||||||
update();
|
update();
|
||||||
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, update);
|
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, update);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user