Highlighted

How can I control Audio with Adobe Animate on a HTML5 canvas?

New Here ,
Apr 04, 2019

Copy link to clipboard

Copied

Hi,

creating Actionscript 3 buttons that controlled audio (play/stop) worked fine for me.
But on a HTML5-Canvas I just cant get it to work.
The start/stop options under properties are also not working with HTML5.

This is my buttons action. Does anybody have an idea what I can add to stop a certain MP3 from playing when clicked?

this.negBtn01.addEventListener("click", fl_ClickToGoToAndStopAtFrame.bind(this));

function fl_ClickToGoToAndStopAtFrame()

{

    this.gotoAndStop("01_neg");

    ??????????? ( WHAT CAN I ADD HERE?) ????????????????

}

If the problem can be solved differently, please let me know.

Views

352

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

How can I control Audio with Adobe Animate on a HTML5 canvas?

New Here ,
Apr 04, 2019

Copy link to clipboard

Copied

Hi,

creating Actionscript 3 buttons that controlled audio (play/stop) worked fine for me.
But on a HTML5-Canvas I just cant get it to work.
The start/stop options under properties are also not working with HTML5.

This is my buttons action. Does anybody have an idea what I can add to stop a certain MP3 from playing when clicked?

this.negBtn01.addEventListener("click", fl_ClickToGoToAndStopAtFrame.bind(this));

function fl_ClickToGoToAndStopAtFrame()

{

    this.gotoAndStop("01_neg");

    ??????????? ( WHAT CAN I ADD HERE?) ????????????????

}

If the problem can be solved differently, please let me know.

Views

353

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
Apr 04, 2019 0
Adobe Community Professional ,
Apr 04, 2019

Copy link to clipboard

Copied

People use different way to control sounds. Below is what I use for example:

Note: I put my code in frame one.

Note2:

play ( src  [interrupt="none"|options]  [delay=0]  [offset=0]  [loop=0]  [volume=1]  [pan=0]  [startTime=null] [duration=null] )

createjs.Sound.play("reset", "none", 0, 0, 0, 0.5);

reset is the link name in library.

function startGame() {

    this.gotoAndStop("game");

    this.music = createjs.Sound.play("music", "none", 0, 0, -1, 0.4);

}

Here is an example for a music button:

//************************* MUSIC BUTTON  ************************

this.musicBtn.addEventListener("click", musicToggle.bind(this));

var on = 0;

function musicToggle() {

    if (on == 0) {

        this.musicBtn.musicStatus.gotoAndStop("musicOff");

        this.music.paused = true;

        on = 1;

    } else {

        this.musicBtn.musicStatus.gotoAndStop("musicOn");

        this.music.paused = false;

        on = 0;

    }

}

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
Reply
Loading...
Apr 04, 2019 1
New Here ,
Apr 08, 2019

Copy link to clipboard

Copied

Thank you resdesign.

I tried that out but it´s not really working for me that way.

Let´s say I have an imported audiofile called "speaker.mp3" which is allready playing at some point (audiowave starting at a certain keyframe).
Now I need a button that doesn´t toggle the sound on and off, but it should only stop that one MP3 from playing.

Since there is background music, not all sounds should stop.

Isn´t there a line of code that will just stop that one audiofile from playing?
Maybe the answer is in your example. But since I have multiple audiofiles a I am looking for a more efficient way of solving this.

Any ideas?

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
Reply
Loading...
Apr 08, 2019 0