• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting past AudioContext chrome blocker - user click

Community Beginner ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

Hi
I can see this was discussed backed in 2019 but I have virtually zero js knowledge. I understand the issue that chrome (canvas) wants the user to click before it will play my audio file and I added a button to do this. Still I get the "It must be resumed (or created) after a user gesture on the page" message.

 

let root = this;
this.mybutt.addEventListener ("click", playSound);

function playSound () {
createjs.Sound.play("mymix");
}

 

 This is my attempt and it works locally.
 
I can see there are posting about resummed and suspend AudioContext but these dont go quite simple enough for my level, ie I cant find the whole piece of code or tutorial. Can anyone signpost me where I can find the whole solution to what must be a very common requirement?
 
Many thanks
Grouse
TOPICS
Code , How to

Views

266

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

what's the link to your html?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

Do you mean the url?  

https://delightfulgreetings.com/soundtest/soundTest.html

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

you have an error in your code.  (ie, learn* to use the developer console of your browser.)

 

specifically, this.currentSoundStreamInMovieclip.instance is undefined

 

 

*

lesson 1 - https://youtu.be/PBDQN9CQSeI

lesson 2 - https://youtu.be/KJEl0OenGUY

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

Thanks for this. I appreciate the "teach a man to fish..." videos and I have gone through them which will stand me in good sted. The bit I am unfamiliar with now is that the code works locally so is it something to do with the AudioContext not being allowed to start is causing ther undefined'ness? If so do I still need ot find a tutorial resource for AudioContext js for beginners?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

that error should appear with local testing too. open the developer console in the local test.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

You are correct of course , the error is there however the sound plays when I click the button locally.

Any other guidance, its getting a bit heavy for my level of knowledge. If not I'll have to get it coded for me as I have spent a whole afternoon googling. Just thought it must be a standard issue for anyone playing audio from a webpage.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

post a link to your fla.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

I have put it as zip so it should download ok. Thanks. Is the whole AudioContext a red herring?

https://delightfulgreetings.com/soundtest/soundTest.zip

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

sound works for me despite the errors when testing and on my server, https://kglad.com/Files/forums/soundTest.html

 

did you remember to upload your published folders (including sound)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

Oh my days!! I re uploaded everything and it works. I am so sorry to have wasted your time, however I now know about debugging.

Thanks ... Im a bit embarrased.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Copy link to clipboard

Copied

LATEST

you're not even close to my record of stupid errors.  part of the reason i!m pretty good at helping others is because of how many errors i make/made and have to fix.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines