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

New Here ,
Nov 05, 2020 Nov 05, 2020

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.

 

TOPICS
ActionScript , Code

Views

193

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 05, 2020 Nov 05, 2020

Copy link to clipboard

Copied

LATEST

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;

}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines