How to fix “audio not playing” issue in HTML project? #81988
-
SummaryHi everyone! 👋 I’ve checked the syntax and tried autoplay, loop, and controls, but nothing seems to work. What else should I try? Additional informationHere’s a snippet of the code I used:
<audio controls autoplay loop>
<source src="./audio/sample.mp3" type="audio/mp3">
</audio> ExampleCurrently testing locally. Can upload to GitHub Pages if needed. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Make sure the audio file path is correct, the file isn't corrupted, and consider testing with a local server (like VS Code Live Server), since some browsers block autoplay or media loading when opened directly from the file system |
Beta Was this translation helpful? Give feedback.
-
corrected code : <title>Audio Test</title>Audio Playback TestMultiple source formats included for better compatibility. Relative path corrected (audio/sample.mp3 without ./). Fallback message added inside the tag. |
Beta Was this translation helpful? Give feedback.
-
hey Test it in multiple browsers: |
Beta Was this translation helpful? Give feedback.
Make sure the audio file path is correct, the file isn't corrupted, and consider testing with a local server (like VS Code Live Server), since some browsers block autoplay or media loading when opened directly from the file system