Error in playing an audio file (mp3) in a server component
Unanswered
Crazy ant posted this in #help-forum
Crazy antOP
I want to play a local audio in server components. can I impletement in a seperate function in client component files and imporing that function in server component? I am getting an error If i am doing so? I tested belowcode by importing in a client component, it's working there! But it is not working in when I import it in a server component.Also let me know If there is any way to play an audio (mp3) in server component.
Server component->
}
"use client"
export default function PlayAudio() {
const audioPlayer = useRef(null)
function playAudio() {
if (sucessLoad ) {
audioPlayer.current.play();
}
}
useEffect(() =>
playAudio()
}, [sucessLoad])
return (
<>
<audio ref={audioPlayer} src="/audio/bell.mp3" />
</>
)
}
Server component->
export default async function BatchProcess( ){
.................
..................
return (
<>
< PlayAudio />
............
.............
</>
)
}