Files
JKVideo/shims/react-native-video.web.tsx
Action 6f7c99906b fix(web): 补全缺失的 web shims 并修复渲染崩溃问题
- 新增 sentry-react-native、react-native-video、react-native-static-server、expo-network、expo-intent-launcher、expo-clipboard、expo-file-system 的 web shim
- 重写 react-native-pager-view shim,通过 useImperativeHandle 暴露 setPage 方法
- 修复 sentry-react-native shim 缺少 ErrorBoundary 导致的渲染崩溃
- 在 _layout.tsx 中加载 Ionicons 字体,修复 web 端字体 404
- 更新 metro.config.js 中 sentry shim 路径为 .tsx
2026-03-24 21:21:15 +08:00

43 lines
1.2 KiB
TypeScript

/** Web shim for react-native-video - uses HTML5 <video> element */
import React from 'react';
interface VideoProps {
source?: { uri?: string } | number;
style?: React.CSSProperties;
paused?: boolean;
muted?: boolean;
repeat?: boolean;
onLoad?: (data: unknown) => void;
onError?: (error: unknown) => void;
onProgress?: (data: unknown) => void;
onEnd?: () => void;
resizeMode?: string;
[key: string]: unknown;
}
const Video = React.forwardRef<HTMLVideoElement, VideoProps>(
({ source, style, paused, muted, repeat, onLoad, onError, onProgress, onEnd }, ref) => {
const uri = typeof source === 'object' && source !== null ? (source as { uri?: string }).uri : undefined;
return (
<video
ref={ref}
src={uri}
style={style as React.CSSProperties}
autoPlay={!paused}
muted={muted}
loop={repeat}
onLoadedData={onLoad ? () => onLoad({}) : undefined}
onError={onError ? (e) => onError(e) : undefined}
onTimeUpdate={onProgress ? (e) => {
const t = e.currentTarget;
onProgress({ currentTime: t.currentTime, seekableDuration: t.duration });
} : undefined}
onEnded={onEnd}
playsInline
/>
);
}
);
export default Video;