HELP! Audio autoplay is not working!! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

HELP! Audio autoplay is not working!!

This is the code I wrote And the audio is in the desktop with the audio html. When I run it. The audio player is showing up but its not playing but itself I had to click the play button to play it. Help me please! <!DOCTYPE html> <html> <head> <title>Audio test</title> </head> <body> <h1> follows an audio</h1> <audio src="Alan Walker - Alone.mp3" autoplay> </audio> </body> </html>

5th Feb 2017, 4:04 AM
Drunk Illuminati
Drunk Illuminati - avatar
5 Answers
+ 6
The audio player shows up really? I thought you need the attribute "controls" for it to show up?
5th Feb 2017, 6:00 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 4
you forgot to put autoplay attribute! <audio autoplay="autoplay" controls="controls">     <source src="music.ogg" />     <source src="music.mp3" />   </audio>
5th Feb 2017, 7:54 AM
Erkindjon Pulatov
Erkindjon Pulatov - avatar
+ 1
Audio file "Alan Walker - Alone.mp3" must be in the same folder where the html file is on your server. if the html is in the root directory of the server, also the audio file must be there. Otherwise yo have to change the audio element in the html file by adding the path before the file name. example (change it with your actual path) <audio src="file://c:/users/user/desktop/Alan Walker - Alone.mp3" autoplay> the catch is it won't be available online for other users.
5th Feb 2017, 4:23 AM
seamiki
seamiki - avatar
+ 1
The chrome doesn't allow autoplay.
9th Jun 2021, 7:27 AM
Code your dreams
Code your dreams - avatar
0
Thanks every one for your help! And thank you very much Erkindjon Pulatov! I tried your code and it's working, but I don't know why my code is not working, I think I have to use the second method sololearn stated in the audio element lesson, the first method to use audio element is not working. And seamiki, yes it is in the same directory and the audio player shows up, but only plays when I click play, it didn't play by itself when I load the page.
5th Feb 2017, 8:56 AM
Drunk Illuminati
Drunk Illuminati - avatar