Skip to main content
New Participant
November 15, 2016
Answered

Play and Stop sound in HTML5 Canvas

  • November 15, 2016
  • 3 replies
  • 10546 views

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 has been closed for replies.
Correct answer Colin Holgate

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();

3 replies

New Participant
August 7, 2020

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();
}

Participating Frequently
November 19, 2020

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

Participating Frequently
November 19, 2020

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

 

 

Brainiac
November 16, 2016

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.

Colin Holgate
Colin HolgateCorrect answer
Inspiring
November 15, 2016

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();