import { AudioWaveform } from '@/components/ui/audio-waveform'; import { Button } from '@/components/ui/button'; import { Text } from '@/components/ui/text'; import { View } from '@/components/ui/view'; import React, { useEffect, useState } from 'react'; export function AudioWaveformInteractive() { const [isPlaying, setIsPlaying] = useState(false); const [progress, setProgress] = useState(0); const [isSeeking, setIsSeeking] = useState(false); // Sample audio data - more realistic pattern const audioData = [ 0.2, 0.4, 0.3, 0.6, 0.8, 0.5, 0.7, 0.9, 0.4, 0.3, 0.5, 0.7, 0.6, 0.8, 0.9, 0.7, 0.5, 0.3, 0.4, 0.6, 0.8, 0.9, 0.7, 0.5, 0.4, 0.6, 0.8, 0.7, 0.5, 0.3, 0.4, 0.6, 0.9, 0.8, 0.6, 0.4, 0.2, 0.3, 0.5, 0.7, ]; // Auto-play simulation useEffect(() => { let interval: number; if (isPlaying && !isSeeking) { interval = setInterval(() => { setProgress((prev) => { if (prev >= 100) { setIsPlaying(false); return 100; } return prev + 1; }); }, 100); } return () => clearInterval(interval); }, [isPlaying, isSeeking]); const handleSeek = (position: number) => { setProgress(position); }; const handleSeekStart = () => { setIsSeeking(true); }; const handleSeekEnd = () => { setIsSeeking(false); }; const togglePlayback = () => { setIsPlaying(!isPlaying); }; const formatTime = (percentage: number) => { const totalSeconds = 180; // 3 minutes total const currentSeconds = (percentage / 100) * totalSeconds; const minutes = Math.floor(currentSeconds / 60); const seconds = Math.floor(currentSeconds % 60); return `${minutes}:${seconds.toString().padStart(2, '0')}`; }; return ( {formatTime(progress)} 3:00 {isSeeking && ( Seeking... )} ); }