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 p5 sound examples to start audio on a user gesture #396

Open
markjsb opened this issue Feb 20, 2019 · 9 comments
Open

update p5 sound examples to start audio on a user gesture #396

markjsb opened this issue Feb 20, 2019 · 9 comments

Comments

@markjsb
Copy link

markjsb commented Feb 20, 2019

Sound is currently not working in Chrome due to changes in the way that sound can be played. It seems that Chrome now only allows a sound context to be created with a user click.

Console log error message:
The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
(anonymous) @ p5.sound.js:211
(anonymous) @ p5.sound.js:292
(anonymous) @ p5.sound.js:73
(anonymous) @ p5.sound.js:74

The error occurs three times, no sound plays.

@aatishb
Copy link
Contributor

aatishb commented Mar 27, 2019

Hi, this is the github for the p5.js website. You might want the p5.js github which is here: https://github.com/processing/p5.js/

For your issue, the easiest way to resolve it is to have the equivalent of a play button, i.e. something that is clicked on the canvas before any sound plays. You could also try the userStartAudio() function from this example: https://p5js.org/reference/#/p5.sound/userStartAudio

@therewasaguy
Copy link
Member

Change was made to the inline examples here processing/p5.js-sound#403 processing/p5.js#3988

and now the examples that live in the website repo also should be updated. The examples should be re-designed to follow the best practice of starting audio (i.e. with userStartAudio()) on a user gesture, i.e. within mousePressed(){}

@stalgiag
Copy link
Contributor

stalgiag commented Jan 6, 2020

@singhvisha do you have any interest in helping out with rewriting some of the samples to follow @therewasaguy 's proposal above?

@vilvadot
Copy link

I'm interested in helping rewriting them @stalgiag but I'm clueless on what direction to take, any help @therewasaguy?

I'm getting the following errors on AudioIn Example:

Chrome Version 79.0.3945.130

The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.

Firefox 73.0.1

{ 
name: "NotFoundError", 
message: "The object can not be found here.", 
constraint: "", 
stack: "" 
}

@singhvisha
Copy link

@stalgiag, Sorry for late answering.I was out of town. I would love to do.

@vilvadot
Copy link

Let me know if you need a hand @singhvisha

@vilvadot
Copy link

I have a working example here: https://github.com/vilvadot/p5-mic-example/blob/master/src/sketch.js

Haven't been able to make it work on Firefox though.

@endurance21
Copy link
Contributor

Change was made to the inline examples here processing/p5.js-sound#403 processing/p5.js#3988

and now the examples that live in the website repo also should be updated. The examples should be re-designed to follow the best practice of starting audio (i.e. with userStartAudio()) on a user gesture, i.e. within mousePressed(){}

@therewasaguy
all examples should be re-designed, is the work still undonen ?
and if yes! you can assign me , i would love to work !
thanks

@therewasaguy
Copy link
Member

@endurance21 yes, we can follow the rewrite that went into the inline examples. processing/p5.js-sound#403 should provide some guidance on how to redesign the examples—thank you for finding and linking that! I apologize I did not already link this in the thread!

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

8 participants