'use client'; import React, { useRef, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Edit3, Play, Pause } from 'lucide-react'; import { ProgressiveReveal, presets } from '@/components/ui/progressive-reveal'; import { GlassIconButton } from '@/components/ui/glass-icon-button'; interface MediaViewerProps { currentStep: string; currentSketchIndex: number; taskSketch: any[]; taskVideos: any[]; isVideoPlaying: boolean; isPlaying: boolean; showControls: boolean; onControlsChange: (show: boolean) => void; onEditModalOpen: (tab: string) => void; onToggleVideoPlay: () => void; onTogglePlay: () => void; } const MOCK_FINAL_VIDEO = { id: 'final-video', url: 'https://cdn.qikongjian.com/videos/1750389908_37d4fffa-8516-43a3-a423-fc0274f40e8a_text_to_video_0.mp4', thumbnail: 'https://d3phaj0sisr2ct.cloudfront.net/app/gen4/object-reference/welcome-ref-1.jpg', }; export function MediaViewer({ currentStep, currentSketchIndex, taskSketch, taskVideos, isVideoPlaying, isPlaying, showControls, onControlsChange, onEditModalOpen, onToggleVideoPlay, onTogglePlay }: MediaViewerProps) { const mainVideoRef = useRef(null); // 视频播放控制 useEffect(() => { if (mainVideoRef.current) { if (isVideoPlaying) { mainVideoRef.current.play().catch(error => { console.log('视频播放失败:', error); }); } else { mainVideoRef.current.pause(); } } }, [isVideoPlaying]); // 当切换视频时重置视频播放 useEffect(() => { if (mainVideoRef.current) { mainVideoRef.current.currentTime = 0; if (isVideoPlaying) { mainVideoRef.current.play().catch(error => { console.log('视频播放失败:', error); }); } } }, [currentSketchIndex]); // 渲染最终成片 const renderFinalVideo = () => (
onControlsChange(true)} onMouseLeave={() => onControlsChange(false)} >
{/* 背景模糊的视频 */} {/* 最终成片视频 */} {/* 操作按钮组 */} {showControls && ( onEditModalOpen('4')} /> )} {/* 视频信息浮层 */}
最终成片
{/* 完成标记 */} 制作完成
); // 渲染视频内容 const renderVideoContent = () => (
onControlsChange(true)} onMouseLeave={() => onControlsChange(false)} > {taskVideos[currentSketchIndex] ? (
{/* 背景模糊的图片 */}
background
{/* 视频 */}
) : (
{`分镜草图
)} {/* 操作按钮组 */} {showControls && ( onEditModalOpen('3')} /> )} {/* 底部播放按钮 */}
); // 渲染分镜草图 const renderSketchContent = () => (
onControlsChange(true)} onMouseLeave={() => onControlsChange(false)} > {taskSketch[currentSketchIndex] ? ( {`分镜草图 ) : (
{/* 动态渐变背景 */} {/* 动态光效 */}
)} {/* 操作按钮组 */} {showControls && ( onEditModalOpen('1')} /> )} {/* 底部播放按钮 */} {/* 播放进度指示器 */} {isPlaying && ( )}
); // 根据当前步骤渲染对应内容 if (Number(currentStep) === 6) { return renderFinalVideo(); } if (Number(currentStep) > 2 && Number(currentStep) < 6) { return renderVideoContent(); } return renderSketchContent(); }