Brent Heigold
Brent Heigold

Reputation: 1273

How can I enable autoplay (not initiated by user) in Firefox?

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

Answers (1)

Dave
Dave

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.

  1. Click the Hamburger (Options Menu).
  2. Pick the Options menu.
  3. In the search textbox, enter "Sound".
  4. A "Block websites from automatically playing sound" option will appear.
  5. Either uncheck that option or click the "Exceptions" button beside it. In my case, I added an exception for https://app.pluralsight.com. It works fine now.

Another option is to use Chrome.

Good luck.

Upvotes: 2

Related Questions