diff --git a/src/components/AudioPlayer.tsx b/src/components/AudioPlayer.tsx index b83ca82..b7327c6 100644 --- a/src/components/AudioPlayer.tsx +++ b/src/components/AudioPlayer.tsx @@ -64,6 +64,12 @@ export const AudioPlayer: React.FC = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [src]); + useEffect(() => { + if (audioRef.current?.duration && audioRef.current.duration !== Infinity) { + setTotalTime(formatTime(audioRef.current.duration)); + } + }, [audioRef.current?.duration]); + useEffect(() => { if (!isNaN(volume)) { const tempVol = volume > 100 ? 100 : volume < 0 ? 0 : volume; @@ -87,6 +93,8 @@ export const AudioPlayer: React.FC = ({ const handleReload = () => { if (audioRef.current) { + setIsPlaying(false); + setTotalTime('--:--'); setCanPlay(false); setHasError(false); audioRef.current.src = src;