bw-expo-app/types/expo-video-migration.d.ts

50 lines
1.1 KiB
TypeScript

// 迁移类型定义 - 兼容 expo-av 到 expo-video 的迁移
import { Video } from 'expo-video';
export type { Video };
// ResizeMode 映射
export const ResizeMode = {
CONTAIN: 'contain' as const,
COVER: 'cover' as const,
STRETCH: 'stretch' as const,
};
export type ResizeMode = 'contain' | 'cover' | 'stretch';
// 兼容性类型
export interface AVPlaybackStatus {
isLoaded: boolean;
isPlaying?: boolean;
durationMillis?: number;
naturalSize?: {
width: number;
height: number;
};
positionMillis?: number;
}
export interface VideoReadyForDisplayEvent {
nativeEvent: {
naturalSize: {
width: number;
height: number;
};
};
}
// Video 组件的兼容性 props
export interface VideoProps {
source: { uri: string };
style?: any;
resizeMode?: ResizeMode;
shouldPlay?: boolean;
isLooping?: boolean;
isMuted?: boolean;
useNativeControls?: boolean;
onReadyForDisplay?: (event: VideoReadyForDisplayEvent) => void;
onError?: (error: any) => void;
onPlaybackStatusUpdate?: (status: AVPlaybackStatus) => void;
ref?: React.RefObject<Video>;
}