import React, { useRef, useState, useEffect } from "react"; interface AudioPlayerProps { urlAudio: string; fileName: string; // ✅ Tambahkan props ini } const AudioPlayer: React.FC = ({ urlAudio, fileName }) => { const audioRef = useRef(null); const [currentTime, setCurrentTime] = useState(0); const playAudio = () => { audioRef.current?.play(); }; const pauseAudio = () => { audioRef.current?.pause(); }; const stopAudio = () => { if (audioRef.current) { audioRef.current.pause(); audioRef.current.currentTime = 0; } }; useEffect(() => { const audio = audioRef.current; if (!audio) return; const updateTime = () => { setCurrentTime(audio.currentTime); }; audio.addEventListener("timeupdate", updateTime); return () => { audio.removeEventListener("timeupdate", updateTime); }; }, []); const formatTime = (time: number) => { const minutes = Math.floor(time / 60); const seconds = Math.floor(time % 60).toString().padStart(2, "0"); return `${minutes}:${seconds}`; }; return (

{fileName}

); }; export default AudioPlayer;