From d495547ee7ae821c47ce27056e50e0838032200a Mon Sep 17 00:00:00 2001 From: orfelorfel23 Date: Sat, 3 Oct 2026 23:12:34 +0200 Subject: [PATCH] fix: MusicPlayer audio source and add volume control --- src/components/MusicPlayer.tsx | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/MusicPlayer.tsx b/src/components/MusicPlayer.tsx index 0900e91..c4c8d70 100644 --- a/src/components/MusicPlayer.tsx +++ b/src/components/MusicPlayer.tsx @@ -18,6 +18,7 @@ export default function MusicPlayer() { const [showLyrics, setShowLyrics] = useState(false); const [lyrics, setLyrics] = useState(null); const [isLoadingLyrics, setIsLoadingLyrics] = useState(false); + const [volume, setVolume] = useState(1); const audioRef = useRef(null); @@ -54,6 +55,12 @@ export default function MusicPlayer() { } }, [isPlaying, currentIndex]); + useEffect(() => { + if (audioRef.current) { + audioRef.current.volume = volume; + } + }, [volume]); + const loadLyrics = async (song: Song) => { setIsLoadingLyrics(true); try { @@ -95,7 +102,7 @@ export default function MusicPlayer() {
+
+ + + + + setVolume(parseFloat(e.target.value))} + style={{ flex: 1, accentColor: 'var(--color-primary)' }} + /> +
+ {showLyrics && (
{isLoadingLyrics ? (