Reputation: 1273
I have one page that launches another page, and the launched page does a series of scrapes and then plays an audio based on the results.
This stopped working today, maybe because of a Firefox update, but I need to be able to enable auto play as it is critical that the audio plays when the launched page loads.
Here is what my current JavaScript code looks like:
function playHighRiskStock(){
var highRiskStock = new Audio('./wav/high-risk.wav');
highRiskStock.play();
}
It is now giving me the error: NotAllowedError: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
It did this all-of-a-sudden (i.e. it was working perfectly yesterday autoplaying with no problems).
How do I configure my browser to allow autoplay, even if not initiated by the user?
I have looked at this page: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide but it doesn't give any actual JavaScript code examples on setting auto play.
Upvotes: 1
Views: 6941
Reputation: 68
I got the same error in Firefox. The following fixed it for me. Didn't need a reboot or to reload the browser.
Another option is to use Chrome.
Good luck.
Upvotes: 2