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

Added stop button for hello audio worklet example #387

Merged
merged 6 commits into from
Jul 30, 2024

Conversation

duojet2ez
Copy link
Contributor

I added a stop button to the hello audio worklet example enabling the user to stop and start the sound.

Specifically, I used audioContext.suspend() to allow the user to pause the sound with a stop button. And I added an isModuleLoaded check to avoid redundantly calling addModule. Also added isPlaying to toggle the playing state.

@duojet2ez
Copy link
Contributor Author

@hoch this is the single example version of my previous PR. Just to update you on getting a test page for quick and easy inspection of the PR, I started looking into this again yesterday and it does seem possible to do with github pages + github actions. I will continue researching this over the course of the week and provide updates.

Copy link
Member

@hoch hoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience, and I am hopeful that we can land this pretty soon.

src/audio-worklet/basic/hello-audio-worklet/main.js Outdated Show resolved Hide resolved
src/audio-worklet/basic/hello-audio-worklet/main.js Outdated Show resolved Hide resolved
src/audio-worklet/basic/hello-audio-worklet/main.js Outdated Show resolved Hide resolved
@duojet2ez
Copy link
Contributor Author

Thanks for the feedback!!

  • I extracted the following lines mentioned and put them in a loadGraph function:

    oscillatorNode = new OscillatorNode(context);
    const bypasser = new AudioWorkletNode(context, 'bypass-processor');
    oscillatorNode.connect(bypasser).connect(context.destination);
    oscillatorNode.start();

  • created a bool isGraphReady to serve as a guard for graph connections in startAudio function

  • removed unnecessary lines 41-51

  • audioContext.resume() placed in click event

  • Click event should now only care about resume and suspend

Copy link
Member

@hoch hoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

It looks like there's a conflict, so once you resolve it I'll merge the PR.

@duojet2ez
Copy link
Contributor Author

Cool I think that should resolve the conflict!

@hoch hoch merged commit 5068b48 into GoogleChromeLabs:main Jul 30, 2024
2 of 3 checks passed
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.

2 participants