How i placed "onload" in an audio? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How i placed "onload" in an audio?

To start the audio when you open the page

29th Jan 2019, 3:23 AM
黑客 ****
黑客 **** - avatar
8 Answers
+ 3
Add the autoplay attribute to the <audio> tag.
29th Jan 2019, 4:09 AM
Rowsej
Rowsej - avatar
+ 2
Have you tried: audio.onload = function() { audio.play(); };
29th Jan 2019, 10:01 PM
Rowsej
Rowsej - avatar
+ 1
But when I have that played in android app
29th Jan 2019, 10:36 AM
黑客 ****
黑客 **** - avatar
+ 1
Sorry, can you please explain your answer some more? I don’t understand.
29th Jan 2019, 9:23 PM
Rowsej
Rowsej - avatar
+ 1
Like in pc when u open the web page the audio play since u open the page but in the app of solo learn in android u cant do this with the attrib auto play due to an error I suppose so I decided use js , I tried use onload but doesn't work
29th Jan 2019, 9:58 PM
黑客 ****
黑客 **** - avatar
+ 1
The error is due to the action play() needs to be "activated" by an user's action
29th Jan 2019, 10:07 PM
黑客 ****
黑客 **** - avatar
+ 1
Hmm.... sorry I’m not sure what to do.
29th Jan 2019, 10:09 PM
Rowsej
Rowsej - avatar
+ 1
Don't worry that's because I'm doing this question too
29th Jan 2019, 10:10 PM
黑客 ****
黑客 **** - avatar