Skip to main content
Participant
Nov 15, 2016 5:42 PM UTC
Answered

Play and Stop sound in HTML5 Canvas

Hi -
I'm having trouble figuring out the correct steps to control sound in the Actions panel.

Client wants music to start after hitting a "Play" button.
They want the music to continue playing until the viewer hits a "Replay" button.

Basically, what I need to do is figure out how to pause the previous instance of the music so it doesn't play over itself when the video replays.

.FLA attached:

valtoukatly.com/BeaconSt_WIP/beaconst.fla 2.zip

This topic is closed to new replies. Start a new post to keep the conversation going.
Colin Holgate
Colin HolgateCorrect answer
Inspiring
Nov 15, 2016 6:13 PM UTC

Your example file doesn't include any sound.

The simplest solution would be to include this line in your replay code, before the this.gotoAndPlay(2) line:

createjs.Sound.stop();

24 replies

Participant
Aug 7, 2020 9:58 PM UTC

Thank you so much Colin_Holgate!!! Stopping sound in html5 canvas worked. Here is what I used

this.NextButton1.addEventListener("click", fl_ClickToGoToAndStopAtFrame.bind(this));

function fl_ClickToGoToAndStopAtFrame()
{
this.gotoAndStop("two");
createjs.Sound.stop();
}

Translate
Participating Frequently
Nov 19, 2020 9:39 PM UTC

Can someone please Share their .fla as i still cannot ge thtis to work. 

Translate
Participating Frequently
Nov 19, 2020 11:07 PM UTC

Can someone please check my .fla and tell me how to stop/mute the sound onclick on the square button?

 

https://files.fm/u/q947hds2g

 

 

Translate
Legend
Nov 16, 2016 4:59 PM UTC

phornschemeier wrote:

Client wants music to start after hitting a "Play" button.
They want the music to continue playing until the viewer hits a "Replay" button.

This sounds like you're saying there should only be music the first time, but not the second or more times.

Translate
Colin Holgate
Colin HolgateCorrect answer
Inspiring
Nov 15, 2016 6:13 PM UTC

Your example file doesn't include any sound.

The simplest solution would be to include this line in your replay code, before the this.gotoAndPlay(2) line:

createjs.Sound.stop();

Translate