1

I am a complete noob, first question on here, so please be gentle! I'm following a basic Javascript for Sound Artists book, but the initial Hello Sound example, seems to not work due to a new need for a gesture input otherwise disabling autoplaying of sound. As I'm going to be exploring and experimenting predominantly with sound, I was wondering if anyone could please advise on a suitable and simple solution to get around this disabled sound issue? Thanks.

var osc = audioContext.createOscillator();
osc.type = "sine";
osc.connect (audioContext.destination);
osc.start (audioContext.currentTime);


  • 1
    _"I'm going to be exploring and experimenting predominantly with sound"_ If you are performing the experimentation, why cannot you perform the user action which precedes outputting the sound? – guest271314 Feb 04 '19 at 16:19
  • 1
    autoplaying sounds are evil. users will hate you. don't do it. – McHat Feb 04 '19 at 16:19
  • of course. I understand the interaction design principles of not bombarding people with sound, but I'm currently just trying to learn web programming. – Karl Sadler Feb 04 '19 at 16:27

1 Answers1

1

I'm going to be exploring and experimenting predominantly with sound, I was wondering if anyone could please advise on a suitable and simple solution to get around this disabled sound issue?

You can create a separate launcher for Chromium or Chrome browsers with the appropriate flag or policy set to disable the default browser policy of disabling autoplay until user gesture.

For example

--ignore-autoplay-restrictions

  • Ignores all autoplay restrictions. It will ignore the current autoplay policy and all restrictions such as playback in a background tab. It should only be enabled for testing.

See Autoplay Policy Changes

guest271314
  • 1
  • 15
  • 104
  • 177
  • ok, this sounds like a good feature to try whilst I'm still playing. – Karl Sadler Feb 04 '19 at 16:32
  • @KarlSadler One alternative for creating a separate launcher at the OS would be to navigate to `chrome://flags` and select `"Enabled"` for `"Autoplay ignores WebAudio playbacks"` option (_"If enabled, autoplay restrictions will be ignored for WebAudio. – Mac, Windows, Linux, Chrome OS"_) – guest271314 Feb 04 '19 at 16:40
  • I used the Chrome flag solution. That is perfect. I wasn't aware of Chrome's flag/policy features. thank you for your response. :) – Karl Sadler Feb 04 '19 at 16:44
  • @KarlSadler Note also, for clarity policies are different than flags see https://stackoverflow.com/questions/40282861/ – guest271314 Feb 04 '19 at 16:47
  • --autoplay-policy=no-user-gesture-required – Davit Gabrielyan Jul 28 '19 at 16:22