Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
}