#Error in playing an audio file (mp3) in a server component

2 messages · Page 1 of 1 (latest)

regal wharf
#

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.

`"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 />
............
.............
</>

)`

}

stark swiftBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)