HTML5 Audio can't play through Javascript unless triggered manually once HTML5 Audio can't play through Javascript unless triggered manually once javascript javascript

HTML5 Audio can't play through Javascript unless triggered manually once


Well, for my purposes, here's what I did:

Luckily, before the user can trigger the behavior to start audio, they have to click a button. I set the volume of the element to 0.0, and have it "play" when they click this button.

After the sound is played silently, I simply set the volume property back to 1.0, and it plays without user intervention just fine.


In my case this was an easy solution:
https://stackoverflow.com/a/28011906/4622767
Copy & paste this in your chrome:

chrome://flags/#autoplay-policy

My web app has many page reload so I can't force the user to press a button every time; but it is for internal usage, so I can force the users to use chrome and configure that option.


I know that in mobile safari any javascript call to play() must be in the same call stack as a user initialted click event. Spoofing the the click with a javascript trigger won't work either.

On my nexus 7 I can confirm that unless the javascript was triggered by a user click, it does not play.