format everything in zed

This commit is contained in:
2025-10-27 18:20:34 +08:00
parent 99c58217c9
commit 4529c58aad
34 changed files with 1927 additions and 1609 deletions

View File

@@ -1,34 +1,33 @@
import { useRef, useEffect } from "react";
export function useAudioPlayer() {
const audioRef = useRef<HTMLAudioElement | null>(null);
useEffect(() => {
audioRef.current = new Audio();
return () => {
audioRef.current!.pause();
audioRef.current = null;
};
}, []);
const playAudio = async (audioUrl: string) => {
audioRef.current!.src = audioUrl;
try {
await audioRef.current!.play();
} catch (e) {
return e;
}
};
const pauseAudio = () => {
audioRef.current!.pause();
};
const stopAudio = () => {
audioRef.current!.pause();
audioRef.current!.currentTime = 0;
};
return {
playAudio,
pauseAudio,
stopAudio,
audioRef
const audioRef = useRef<HTMLAudioElement | null>(null);
useEffect(() => {
audioRef.current = new Audio();
return () => {
audioRef.current!.pause();
audioRef.current = null;
};
}, []);
const playAudio = async (audioUrl: string) => {
audioRef.current!.src = audioUrl;
try {
await audioRef.current!.play();
} catch (e) {
return e;
}
};
const pauseAudio = () => {
audioRef.current!.pause();
};
const stopAudio = () => {
audioRef.current!.pause();
audioRef.current!.currentTime = 0;
};
return {
playAudio,
pauseAudio,
stopAudio,
audioRef,
};
}