Skip to main content
Known Participant
September 28, 2021
Answered

HTML5 Audio Control

  • September 28, 2021
  • 2 replies
  • 374 views

Hello, I am trying to control audio and timeline in an HTML5 document in Animate. My Pause and Play buttons are not working correctly. They work for the timeline but not the audio. In my main Scene 1 timeline I have an mc named S2. On my Actions layer in frame 1 of S2 I have:

var soundS2 = createjs.Sound.play("mysound");
soundS2.play();

I then have another 1-frame mc called Nav that holds the navigation and control buttons on another layer in S2.  On frame 1 of  Nav I have:

this.pause_btn.addEventListener("click", fl_MouseClickHandler_4.bind(this));
function fl_MouseClickHandler_4(){
	this.parent.stop();
	this.parent.soundS2.pause();
}

this.play_btn.addEventListener("click", fl_MouseClickHandler_5.bind(this));
function fl_MouseClickHandler_5(){
	this.parent.play();
	this.parent.soundS2.play();
}

 

When launched the sould plays, but it does't pause. The timeline, however, will pause and play. I saw on another post that if I make an instance of the createjs.Sound.play("mysound"), that I can control the instance with a pause() and play() functions.

 

My end result would be to have both the sound and timeline pause, then start at the same spot when the user click the play button.

 

Any help here would be greatly appreciated.

Thank you!

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

It should be:

this.parent.soundS2.paused = true;

 

Regards,

JC

2 replies

Participant
September 30, 2021

I am also facing similar issue on my blog https://myuniversalremotecodes.com

Adobe JS is not loaded properly I have tried each and everything how do I fix it?

Known Participant
September 28, 2021
this.soundS2 = createjs.Sound.play("mysound");
soundS2.play();

I saw that my soundS2 was not defined in the debugger so I fixed that.  But the error now says Pause is not a function. So, I guess I need to know the right syntax to use here on my button script.

this.pause_btn.addEventListener("click", fl_MouseClickHandler_4.bind(this));
function fl_MouseClickHandler_4(){
	this.parent.stop();
	this.parent.soundS2.pause();
}
JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
September 28, 2021

Hi.

 

It should be:

this.parent.soundS2.paused = true;

 

Regards,

JC

Known Participant
September 28, 2021

Thank you JC! Many blessings to you.

Shannon