Skip to main content
Inspiring
March 4, 2020
Answered

HTML5 Sound issues in 20.0.2

  • March 4, 2020
  • 5 replies
  • 2516 views

I just updated to 20.0.2 and now none of my sounds work (HTML5 canvas doc).

 

Sounds added to the timeline don't make a sound

 

Sounds played via javascript get an error ("TypeError: Cannot read property 'startTime' of undefined")

This topic has been closed for replies.
Correct answer Colin Holgate

I think that some of those example commands are for people using CreateJS outside of Animate, and if CreateJS changed, maybe some of those examples don't work the same anymore.

 

For me, I double-click the Link column in Library, for the sound I'm using, type in "test", then this line works fine:

 

createjs.Sound.play("test");

 

To tie it to a movieclip named 'red', I have this:

 

this.red.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler(){
createjs.Sound.play("test");
}
 
If I add the other parameters, then I get script errors.

 

5 replies

Participating Frequently
November 28, 2020

Hello,

 

Could we change the volume with your solution?

 

Best regards

Colin Holgate
Inspiring
March 10, 2020

Previously you would have to do a user action on mobile to start sound working. It looks that's now the case with desktop browsers, at least some. On macOS Catalina, Safari and Chrome need you to do a mouse click, but Microsoft Edge and Firefox don't.

 

What was the Javascript you did, and the error that you saw?

DaveAdlerAuthor
Inspiring
March 10, 2020

Right, sometimes sounds won't play before a user click. In all my cases, there is a user click.

 

The javascript command I'm using is

 

createjs.Sound.play("mySoundLinkageName", false, 0, 0, 0, 1);

 

and the error I get is

 

TypeError: Cannot read property 'startTime' of undefined

 

which is generated from the "compiled" javascript

 

var d=createjs.PlayPropsConfig.create(b),e=c.createInstance(a,d.startTime,d.duration),f=c._playInstance(e,d);

 

(i.e., I don't have a startTime var attached to anything, it comes from createJs or Animate)

 

The same javascript works fine in v18 and v19, no errors.

Colin Holgate
Colin HolgateCorrect answer
Inspiring
March 10, 2020

I think that some of those example commands are for people using CreateJS outside of Animate, and if CreateJS changed, maybe some of those examples don't work the same anymore.

 

For me, I double-click the Link column in Library, for the sound I'm using, type in "test", then this line works fine:

 

createjs.Sound.play("test");

 

To tie it to a movieclip named 'red', I have this:

 

this.red.addEventListener("click", fl_MouseClickHandler.bind(this));
function fl_MouseClickHandler(){
createjs.Sound.play("test");
}
 
If I add the other parameters, then I get script errors.

 

Community Expert
March 7, 2020

Make sure you have it on stream.

DaveAdlerAuthor
Inspiring
March 9, 2020

Can't put it on stream in HTML5 Canvas, there is only option for "event" in HTML5 Canvas development.

DaveAdlerAuthor
Inspiring
March 6, 2020

Well I guess I'll let this issue go dormant if no one else has it. I tried re-importing the sounds, no luck. Nothing plays on the timeline. I didn't have anything starting on the first frame, which was a known issue at one time.

 

Again, javascript sounds (createjs.Sound.play) work in 19.2....v20 moved to a different version of createjs, and that's where the problem with javascript sounds probably lies. CreateJs is throwing an error for some reason, where it didn't before.

 

But since I moved back to 19.2, javascript sounds work again. So instead of timeline sounds, I include javascript on the same frame that just plays the sound using createjs.Sound.play. I of course had to give each sound a linkage name to do this.

 

Works just the same now as it did before: had to go back a version of Animate (and therefore createjs) and add javascript code to do what the frame's "sound" specification was supposed to do.

 

So for now, no using timeline sounds, and I'm sticking with 19.2 until 20.0.2 and createjs work their sound issues out.

DaveAdlerAuthor
Inspiring
March 6, 2020

update: went back to 19.2...(couldn't go back to 18 unfortunately).

 

Now sounds triggered by Javascript (createjs.Sound.play) work again (they don't throw an error).

 

But timeline sounds are not working. No error, but no sound.

 

Come on, there's no way we went all the way through v19 with this being the case, right? But for the life of me I can't imagine why sounds put on a frame in the timeline would work in v18 and not work in v19 and v20.

 

Anyone else had this? Or maybe I should ask: do your timeline sounds work in v19 or v20 ?