fix: 음악자동재생 + 버그수정
This commit is contained in:
1 parent
2988a59749
commit
0e5a63a28b
3 files changed
+45
-23
No files matched your search
@@ -53,7 +53,7 @@ function IconMusic() {
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
function IconVolume({ level }: { level: number; muted: boolean }) {
|
||||
function IconVolume({ level }: { level: number }) {
|
||||
if (level === 0) {
|
||||
return (
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
||||
@@ -145,10 +145,10 @@ export default function MusicBar() {
|
||||
loadPlaylist,
|
||||
} = usePlayer();
|
||||
|
||||
// 경로가 바뀌면 해당 경로의 플레이리스트 로드
|
||||
// 경로가 바뀌면 해당 경로의 플레이리스트 로드, 없으면 초기화
|
||||
useEffect(() => {
|
||||
const tracks = PATH_PLAYLISTS[pathname];
|
||||
if (tracks) loadPlaylist(tracks);
|
||||
loadPlaylist(tracks ?? []);
|
||||
}, [pathname, loadPlaylist]);
|
||||
|
||||
if (!hasTrack) return null;
|
||||
@@ -171,9 +171,10 @@ export default function MusicBar() {
|
||||
};
|
||||
|
||||
const handleVolumeDrag = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
const el = e.currentTarget;
|
||||
el.setPointerCapture(e.pointerId);
|
||||
const update = (ev: PointerEvent) => {
|
||||
const rect = (e.currentTarget as HTMLDivElement).getBoundingClientRect();
|
||||
const rect = el.getBoundingClientRect();
|
||||
setVolume(Math.max(0, Math.min(1, (ev.clientX - rect.left) / rect.width)));
|
||||
};
|
||||
const stop = () => {
|
||||
@@ -313,10 +314,10 @@ export default function MusicBar() {
|
||||
{/* 볼륨 — 모바일 포함 전체 표시 */}
|
||||
<button
|
||||
onClick={toggleMute}
|
||||
aria-label={muted ? t.playerPlay : t.playerPause}
|
||||
aria-label={muted ? t.playerUnmute : t.playerMute}
|
||||
className="p-1 text-white/45 hover:text-white/80 transition-colors shrink-0"
|
||||
>
|
||||
<IconVolume level={displayVolume} muted={muted} />
|
||||
<IconVolume level={displayVolume} />
|
||||
</button>
|
||||
<div
|
||||
className="w-16 md:w-20 h-[3px] bg-white/20 rounded-full cursor-pointer shrink-0 relative"
|
||||
|
||||
Reference in new issue
Block a user