skip to Main Content

Heres my code :
<audio loop autoplay> <source src="song.mp3" type = "audio/mpeg"> </audio>
my "song" folder is saved in the same directory as the code file , so that cant be the issue ,the problem is that the song isnt running in the background as i want it to .

its very frustrating cus i havent really found anything in terms of troubleshooting ; can somebody please help!

2

Answers


  1. Your browser does not support the audio element.

    If you write a code like above, it will solve all errors that you were facing.
    This code:

    Adding muted resolves autoplay restrictions.
    The./ ensures the correct file path is used.
    Testing the file ensures it’s properly encoded.

    Login or Signup to reply.
  2. It could be the browser, it could be the location or it could be the typo you’ve made on "audio/mpeg". Add "controls" so you can check if you can play it that way and check your console for possible errors:

    <audio loop autoplay controls>
        <source src="song.mp3" type="audio/mp3">
    </audio>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search