Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update examples to reflect new Audio Autoplay Policy #2911

Closed
TomPeak opened this issue May 16, 2018 · 12 comments
Closed

update examples to reflect new Audio Autoplay Policy #2911

TomPeak opened this issue May 16, 2018 · 12 comments
Milestone

Comments

@TomPeak
Copy link

TomPeak commented May 16, 2018

Hello,

I use p5.sound on Chrome

please have a look: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio

I get this error:
The AudioContext was not allowed to start. It must be resume (or created) after a user gesture on the page. https://goo.gl/7K7WLu

There are some 2018 chances!

Tom

@lmccart lmccart closed this as completed May 16, 2018
@lmccart lmccart reopened this May 16, 2018
@lmccart
Copy link
Member

lmccart commented May 16, 2018

I think the todo here is to add a note into the documentation and update any examples that autoplay to instead require user interaction (mousePressed etc).

@lmccart lmccart changed the title Audio Autoplay Policy update examples to reflect new Audio Autoplay Policy May 16, 2018
@lmccart
Copy link
Member

lmccart commented May 16, 2018

note that the documentation for sound examples is done here: https://github.com/processing/p5.js-sound

@limzykenneth
Copy link
Member

For now this behaviour has been at least temporarily suspended, furthermore what Chrome is doing isn't standard compliant. How Chrome will or will not change their approach to this is still to be seen.

@lmccart
Copy link
Member

lmccart commented Jul 2, 2018

this would mean updating files p5.dom.js and maybe also p5.Element.js. there are probably updates needed for the p5.sound library as well, but those live in a separate repo

@micuat
Copy link
Member

micuat commented Aug 7, 2018

I've encountered this problem with latest chrome when playing videos. Muted video can be autoplayed but video.volume(0) is not enough - only video.elt.muted = true works

@tigoe
Copy link

tigoe commented Feb 17, 2019

It's not just audio playback, I'm getting the same error when I try to use AudioIn and fft to do tone detection.

See https://github.com/tigoe/p5js_examples/tree/master/toneDetect for an example that fails reliably.

@dhowe
Copy link
Contributor

dhowe commented Feb 18, 2019

Seems to me we either need to fix the fatal bugs (eg https://github.com/processing/p5.js-sound/issues/88) in p5.sound or give up on it and instruct folks to use something like Tone.js. If the latter, then we don't need to worry too much about this... (its quite frustrating for students who are instructed to use the sound lib, to then have it crash their sketches whenever they let them run for a while)

@stalgiag
Copy link
Contributor

stalgiag commented Mar 15, 2019

Just putting a note here that the above issue was fixed with #3608, seems reasonable to move forward with updating examples/documentation in time for 0.8.0 release

@lmccart lmccart modified the milestones: 0.8.0, 0.9.0 Mar 25, 2019
@lmccart lmccart modified the milestones: 0.9.0, 0.10.0 Jul 1, 2019
@lmccart lmccart modified the milestones: 0.10.0, 1.0.0 Oct 14, 2019
@fadookie
Copy link

fadookie commented Oct 16, 2019

I can't get this to work reliably on my latest sketch: https://editor.p5js.org/fadookie/sketches/RM4wd2g8U

In the editor, it works fine. But as soon as I download or show in fullscreen or presentation mode, I sometimes am unable to get any audio line in EVEN after waiting for a click event as suggested in the docs.

Sometimes it works without any user interaction, sometimes it never works, seemingly at random! And it's confusing because in the event the audio line in fails to start, I get a success callback from AudioIn#start rather than an error callback. I've never seen my error callback fire even once. I know this is mostly Chrome's fault but it's making p5.js barely usable for making audio-reactive sketches.

Does anyone have any advice? Is there a more sure-fire way to wait for "user interaction" other than just waiting for a click on the canvas? Should I be re-creating the AudioIn? How can I tell my users what to do so it works? It also seems like there's a bug in #start such that errors don't actually get bubbled up.

@limzykenneth
Copy link
Member

@fadookie I don't think this is related to the autoplay policy as the behaviour does not include microphone access. Chrome and other browsers usually ask for user permission before accessing them (with default settings), basically the same behaviour as webcams. I have no idea why Chrome is giving this behaviour though, nothing I found online points to a potential source of the problem.

@fadookie
Copy link

fadookie commented Oct 21, 2019

Thanks, maybe I should open a separate issue with this. May be PEBKAC but would still be great to document better if so.

Edit: Moved to separate issue: https://github.com/processing/p5.js/issues/4112

@lmccart
Copy link
Member

lmccart commented Jan 6, 2020

fixed with #3988. there is more work planned with p5.sound to address the way the audio context is initiated, but this partially resolves the issue in the meantime

@lmccart lmccart closed this as completed Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants