Next.js Discord

Discord Forum

Module not found

Answered
Crested Caracara posted this in #help-forum
Open in Discord
Avatar
Crested CaracaraOP
Hello,
I am trying to add some sounds in my website but I can't import them. Can someone help me?

The import statement :
import environnement from 'assets/audio/environnement.mp3';


The error :
Image
Answered by Barbary Lion
Sadly I have never used sounds/videos in NextJS yet, but have you tried the answers from this post?
https://www.reddit.com/r/nextjs/comments/xfjxhv/how_to_play_sound_on_button_click_in_nextjs_app/

Maybe this helps your case, not sure
View full answer

5 Replies

Avatar
Barbary Lion
Sadly I have never used sounds/videos in NextJS yet, but have you tried the answers from this post?
https://www.reddit.com/r/nextjs/comments/xfjxhv/how_to_play_sound_on_button_click_in_nextjs_app/

Maybe this helps your case, not sure
Answer
Avatar
Barbary Lion
Also, since you're getting a "module-not-found" error, I am guessing that you haven't specified the right path for the file. Is the sound file in the public folder?
Avatar
Crested CaracaraOP
Oh thank u, I have tried by passing the import path as a parameter and it's working.
Now I have another issue, I know that some bowers not allow us to autoplay sounds unless I click somewhere but do you know if there is a way to bypass this restriction?
I don't think so, so maybe I will ask to click after the loading completed in order to access to the website