import React, { useState } from 'react';
import { View, StyleSheet, Dimensions, Text, Platform, Modal, StatusBar } from 'react-native';
import { NativeVideoPlayer } from './NativeVideoPlayer';
import type { PlayUrlResponse } from '../services/types';
const { width } = Dimensions.get('window');
const VIDEO_HEIGHT = width * 0.5625;
interface Props {
playData: PlayUrlResponse | null;
qualities: { qn: number; desc: string }[];
currentQn: number;
onQualityChange: (qn: number) => void;
onMiniPlayer?: () => void;
bvid?: string;
cid?: number;
}
export function VideoPlayer({ playData, qualities, currentQn, onQualityChange, onMiniPlayer, bvid, cid }: Props) {
const [fullscreen, setFullscreen] = useState(false);
if (!playData) {
return (
视频加载中...
);
}
if (Platform.OS === 'web') {
const url = playData.durl?.[0]?.url ?? '';
return (
);
}
return (
<>
setFullscreen(true)}
onMiniPlayer={onMiniPlayer}
bvid={bvid}
cid={cid}
/>
setFullscreen(false)}
bvid={bvid}
cid={cid}
style={{ width: '100%', height: '100%' } as any}
/>
>
);
}
const styles = StyleSheet.create({
container: { width, height: VIDEO_HEIGHT, backgroundColor: '#000' },
placeholder: { justifyContent: 'center', alignItems: 'center' },
placeholderText: { color: '#fff', fontSize: 14 },
fullscreenContainer: { flex: 1, backgroundColor: '#000' },
});