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. 

JoãoCésar17023019
Community Expert
Community Expert
November 20, 2020

So that code you wrote was fresh and unique to the code in the thread.

I still dont really understand what you did but it works.!

 

Can you maybe recommend a beginners tutorial that could maybe help me understand what you wrote?

Book or Video?

 

Thank you one again! 

Took me a whole day to try that and i stilll failed. fml.

+)

 


Here are some suggestions for learning materials:

 

- The official help has lot of articles, tutorials, and examples: https://helpx.adobe.com/support/animate.html;

- Animate CC also ships with great learning content. Just go to the start screen and select the LEARN option in the top-left corner of the screen;

- LinkedIn Learning has some great video courses (special mention to Joseph Labrecque): https://www.linkedin.com/learning/;

- Pluralsight also have some great video courses: https://www.pluralsight.com/;

- General tips and tricks in the comment that starts with "Excellent!";

- Official demos developed by the CreateJS team: https://github.com/CreateJS/AdobeAnimateDemo;

- Official Flappy Bird clone tutorial: https://theblog.adobe.com/building-a-html5-flappy-bird-game-clone-with-adobe-animate-cc/ ;
- Adobe Animate's official YouTube channel;

- Martin Melendez's YouTube channel;

- My repo on GitHub that contains the source codes and files of some games and other stuff;

- I also have a YouTube channel that you may find useful.

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