Use onMediaUnsupported on android too

This commit is contained in:
Zoe Roux 2024-02-01 00:51:18 +01:00
parent 8c910fa532
commit 6265f9bc2c
2 changed files with 7 additions and 2 deletions

View File

@ -32,7 +32,7 @@ export type Snackbar = {
key?: string; key?: string;
label: string; label: string;
duration: number; duration: number;
actions: Action[]; actions?: Action[];
}; };
export type Action = { export type Action = {

View File

@ -64,7 +64,7 @@ const videoAtom = atom(0);
const clientId = uuid.v4() as string; const clientId = uuid.v4() as string;
const Video = forwardRef<VideoRef, VideoProps>(function Video( const Video = forwardRef<VideoRef, VideoProps>(function Video(
{ onLoad, onBuffer, source, subtitles, ...props }, { onLoad, onBuffer, onError, onMediaUnsupported, source, subtitles, ...props },
ref, ref,
) { ) {
const { css } = useYoshiki(); const { css } = useYoshiki();
@ -98,6 +98,11 @@ const Video = forwardRef<VideoRef, VideoProps>(function Video(
onLoad?.(info); onLoad?.(info);
}} }}
onBuffer={onBuffer} onBuffer={onBuffer}
onError={(e) => {
// 24001 is codec error
if (e.error.errorCode === "24001") onMediaUnsupported?.();
else onError?.(e);
}}
selectedVideoTrack={ selectedVideoTrack={
video === -1 video === -1
? { type: SelectedVideoTrackType.AUDO } ? { type: SelectedVideoTrackType.AUDO }