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

Start audio context #322

Merged
merged 8 commits into from
Jan 10, 2019
Merged

Conversation

therewasaguy
Copy link
Member

following up on #283

This pulls in Yotam Mann's StartAudioContext.

I got a bit sidetracked looking at his new library UnmuteButton which would be another very cool solution. But it would involve upgrading to Tone 13.2, and shimming the unmute library (which uses class) to es5 or making p5.sound es6 friendly. If anyone wants to take this on that would be amazing.

In the meantime, this PR:

  • adds a userStartAudio method
  • adds a dependencey on StartAudioContext

To test:

  • launch Chrome Canary (70+) from the terminal with the following --disable-features flags, i.e.
/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary
--disable-features=PreloadMediaEngagementData,AutoplayIgnoreWebAudio,MediaEngagementBypassAutoplayPolicies

Here's a little sketch to test—it should alert and remove the button after userStartAudio succeeds

function setup() {
  var ac = getAudioContext();

  ac.suspend().then(function() {
    var myButton = createButton('click to start audio');
    myButton.position(0, 0);

    userStartAudio(myButton, function() {
      alert(ac.state);
      myButton.remove();
    });
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant