- Integrate togglePlayPause, getNextIndex, getPrevIndex, handleRepeatOrNext, seekTo, toggleShuffle, setAudioVolume, toggleMute library functions - Fix ESLint warnings: remove unused eslint-disable, add missing useEffect dependencies - Fix ESLint error in useMusicPlayer.ts togglePlayPause function - Add force-dynamic export to root layout to prevent prerendering errors - Improve seek slider with preview/commit functionality - Add isSeeking state to prevent UI flickering during seek Fixes: Build PageNotFoundError for admin/darmasaba pages Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
24 lines
501 B
TypeScript
24 lines
501 B
TypeScript
import { RefObject } from "react";
|
|
|
|
export function togglePlayPause(
|
|
audioRef: RefObject<HTMLAudioElement | null>,
|
|
isPlaying: boolean,
|
|
setIsPlaying: (v: boolean) => void
|
|
) {
|
|
if (!audioRef.current) return;
|
|
|
|
if (isPlaying) {
|
|
audioRef.current.pause();
|
|
setIsPlaying(false);
|
|
} else {
|
|
audioRef.current
|
|
.play()
|
|
.then(() => setIsPlaying(true))
|
|
.catch(console.error);
|
|
}
|
|
}
|
|
|
|
// pakai di ui
|
|
// onClick={() =>
|
|
// togglePlayPause(audioRef, isPlaying, setIsPlaying)
|
|
// }
|