Skip to main content
Participating Frequently
April 27, 2023
Answered

How to stop specific sound in html 5 canvas?

  • April 27, 2023
  • 1 reply
  • 1854 views

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 has been closed for replies.
Correct answer JoãoCésar17023019

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

1 reply

JoãoCésar17023019
Community Expert
Community Expert
April 27, 2023

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

DeSutaAuthor
Participating Frequently
April 27, 2023

Ok i will try it

kglad
Community Expert
Community Expert
April 27, 2023

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.