+ 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>
5 ответов
+ 6
The audio player shows up really? I thought you need the attribute "controls" for it to show up?
+ 4
you forgot to put autoplay attribute!
<audio autoplay="autoplay" controls="controls"> <source src="music.ogg" /> <source src="music.mp3" /> </audio>
+ 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.
+ 1
The chrome doesn't allow autoplay.
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.