import React, { useRef, useState } from 'react'; import { Box, Typography } from '@mui/material'; import Slider from 'rc-slider'; import 'rc-slider/assets/index.css'; import BaseFileInput from './BaseFileInput'; import { BaseFileInputProps, formatTime } from './file-input-utils'; interface VideoFileInputProps extends Omit { showTrimControls?: boolean; onTrimChange?: (trimStart: number, trimEnd: number) => void; trimStart?: number; trimEnd?: number; accept?: string[]; } export default function ToolVideoInput({ showTrimControls = false, onTrimChange, trimStart = 0, trimEnd = 100, accept = ['video/*', '.mkv'], ...props }: VideoFileInputProps) { const videoRef = useRef(null); const [videoDuration, setVideoDuration] = useState(0); const onVideoLoad = (e: React.SyntheticEvent) => { const duration = e.currentTarget.duration; setVideoDuration(duration); if (onTrimChange && trimStart === 0 && trimEnd === 100) { onTrimChange(0, duration); } }; const handleTrimChange = (start: number, end: number) => { if (onTrimChange) { onTrimChange(start, end); } }; return ( {({ preview }) => ( )} ); }