'use client'; import { Box, Typography, IconButton, Slider, useTheme } from '@mui/material'; import { PlayArrow, Pause, VolumeUp } from '@mui/icons-material'; import { useRef, useState } from 'react'; export default function AudioPlayer({ src, title }: { src: string; title: string }) { const audioRef = useRef(null); const [playing, setPlaying] = useState(false); const [volume, setVolume] = useState(100); const theme = useTheme(); const togglePlay = () => { const audio = audioRef.current; if (!audio) return; if (playing) { audio.pause(); } else { audio.play(); } setPlaying(!playing); }; const handleVolumeChange = (event: Event, newValue: number | number[]) => { const audio = audioRef.current; if (!audio) return; const vol = typeof newValue === 'number' ? newValue : newValue[0]; setVolume(vol); audio.volume = vol / 100; }; return ( {title} {playing ? : } ); }