Skip to main content
Participant
November 5, 2020
Question

Adobe Animate HTML5/Canvas play and pause sound on the same button

  • November 5, 2020
  • 1 reply
  • 570 views

Hi! I am new to Adobe Animate program. I want the play and pause features in html5 / canvas to be on the same button. When you click the play button, the sound will be played, when you click the pause button, the sound will stop and when you click the play button again, the sound will continue from where it left off. Can you help me! Thanks.

 

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
November 5, 2020

if(!yourbutton.hasEventListener){

this.toggle = true;

yourbutton.addEventListener("click",playSoundF.bind(this));

}

 

function playSoundF(e){

if(this.toggle){

if(!this.soundID){

this.soundID = createjs.Sound.play("linkageID");  //<-assign linkage id to sound in your library

} else {

this.soundID.play();

}

} else {

this.soundID.stop();

}

this.toggle = !this.toggle;

}