Skip to main content
Participating Frequently
Apr 27, 2023 10:55 AM UTC
Answered

How to stop specific sound in html 5 canvas?

I already try using createjs.Sound.stop("sound1") ; in frame 2

But it also stop my background music. 

 

I already give correct linkage name for sound1 but it still not working. 

 

Is there any solution or other way to stop specific sound in html5 canvas? 

This topic is closed to new replies. Start a new post to keep the conversation going.
JoãoCésar17023019
JoãoCésar17023019Correct answer
Community Expert
Apr 27, 2023 4:39 PM UTC

Please check out this example of how to create a navigation between frames/screens, playing sound effects while maintaining a background music.

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/narrated_story

20 replies

JoãoCésar17023019
Community Expert
Community Expert
Apr 27, 2023 11:37 AM UTC

Hi.

 

You have to store the sound in a variable or property when calling the static play method from the Sound class and then call the stop method on this same variable/property. Like this:

// when playing
var yourSound = createjs.Sound.play("YourLibrarySoundLinkage");

// somewhere else
yourSound.stop();

 

I hope this helps.

 

Regards,

JC

Translate
DeSutaAuthor
Participating Frequently
Apr 27, 2023 11:42 AM UTC

Ok i will try it

Translate
kglad
Community Expert
Community Expert
Apr 27, 2023 2:45 PM UTC

or put your sounds on different timelines with their sync property set to stream and start and stop the timelines whose sounds you want to start and stop.

Translate