Can't get local mp3 to play in audio tag; web hosted file works

So I’m trying to do the 25 + 5 clock project in the front end cert, and I’m trying to add an alarm sound. What I’ve noticed is that when I try to link an audio source locally, I get

Uncaught (in promise) DOMException: The media resource indicated by the src attribute or assigned media provider object was not suitable.
HTTP “Content-Type” of “text/html” is not supported. Load of media resource http://localhost.localdomain:3000/public/assets/Softchime.mp3 failed.

For more context, I’m running this locally through vscode (bootstrapped using CRA). I have a conditional inside a useeffect that has an audio element/object play when the timer reaches 0. For whatever reason, when I use a web-hosted audio file it plays fine with no errors in the console. However, if I try to use a locally stored file I get the above errors.

Github link: GitHub - Wangstaboi/pomodoro-timer at test

That’s uh… wow don’t know why I didn’t think of that when I already have it on github :person_facepalming: .

Github link: GitHub - Wangstaboi/pomodoro-timer at test

Fixed the problem. Turns out when I add the path I don’t need the “public” part. Something to do with how webpack bundles everything.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.