const Timeline = ({ duration, currentTime, onSeek, transcriptions }) => { const formatTime = (seconds) => { const m = Math.floor(seconds / 60); const s = Math.floor(seconds % 60); return `${m}:${s.toString().padStart(2, '0')}`; }; const handleClick = (e) => { const rect = e.currentTarget.getBoundingClientRect(); const x = e.clientX - rect.left; const percent = Math.max(0, Math.min(1, x / rect.width)); onSeek(percent * duration); }; return (
{formatTime(currentTime)} {formatTime(duration)}
{/* Segments */} {transcriptions.map((t, i) => { // Convert "00:00:03.500" to seconds const parseTime = (timeStr) => { const [h, m, s] = timeStr.split(':'); return parseInt(h) * 3600 + parseInt(m) * 60 + parseFloat(s); }; const start = parseTime(t.start); const end = parseTime(t.end); const left = (start / duration) * 100; const width = ((end - start) / duration) * 100; // Determine color based on speaker const isVoiceover = t.contains_voiceover; return (
); })} {/* Scrubber Head */}
); }; window.Timeline = Timeline;