Skip to main content
Participant
November 15, 2016
해결됨

Play and Stop sound in HTML5 Canvas

  • November 15, 2016
  • 3 답변들
  • 10578 조회

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

이 주제는 답변이 닫혔습니다.
최고의 답변: 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 답변

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

 

 

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