/** * VideoPlayerModal 视频播放弹窗组件 * 全屏模态播放视频,基于 expo-video */ import React, { useCallback } from 'react'; import { Modal, View, StyleSheet, Dimensions, TouchableOpacity, Text, StatusBar, } from 'react-native'; import { VideoView, useVideoPlayer } from 'expo-video'; import { MaterialCommunityIcons } from '@expo/vector-icons'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { spacing, fontSizes, borderRadius } from '../../theme'; const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window'); export interface VideoPlayerModalProps { /** 是否可见 */ visible: boolean; /** 视频 URL */ url: string; /** 关闭回调 */ onClose: () => void; } /** * 视频播放器内容 - 独立组件,仅在弹窗可见时挂载,避免预加载 */ const VideoPlayerContent: React.FC<{ url: string; onClose: () => void }> = ({ url, onClose }) => { const insets = useSafeAreaInsets(); const player = useVideoPlayer(url, (p) => { p.loop = false; p.play(); }); const handleClose = useCallback(() => { player.pause(); onClose(); }, [player, onClose]); return (