Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Play and Stop an audio with animate cc

New Here ,
Feb 29, 2016 Feb 29, 2016

Good evening, i'm new to the flash/animate universe and i have some questions about it.

I'm trying to create an html5 canvas document where there is a button who has to play and stop a sound.

Following a tutorial instruction i have been able to animate the button and make it sound after the is clicked, but i need to use it also to stop the sound.

How can i do that?

thanks for answers

TOPICS
How to
19.1K
Translate
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
LEGEND ,
Feb 29, 2016 Feb 29, 2016
Translate
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
New Here ,
Feb 29, 2016 Feb 29, 2016

thanks but i'm trying to do it not with code, or i'd used a library but using  the animate button states and code snippets. the problem is that when i add an audio file to the button i just can play it as an event, i don't know how to use the stop event because the software does not make me select it

Translate
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
LEGEND ,
Feb 29, 2016 Feb 29, 2016

You can't do this without code (and code snippets are, of course, code).

How, exactly, are you currently making the audio file play?

Translate
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
New Here ,
Feb 29, 2016 Feb 29, 2016

hi man, sorry if i had not thank you before for the answer but i was on mobile, i'll do now for both answers D.

It's my first time with easejs so i still don't know functions and code snippets. I have a button. I imported into the library a sound that i want to play when it is pressed. I double clicked on the button and i created a keyframe for the down state of the button and i used it to play the audio.

I don't know why if i go on another frame why i can't select the "stop" event and give it to a button state

Translate
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
LEGEND ,
Feb 29, 2016 Feb 29, 2016

I'm going to assume that by "used it to play the audio", you mean you placed the audio directly on the timeline. In that case, the only way to stop it prematurely is with this:

createjs.Sound.stop();

This will kill ALL currently playing audio.

Translate
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
New Here ,
Feb 29, 2016 Feb 29, 2016

No i imported it into the library. I would make a screenshot of it, but unfortunately the app is in italian so i think that it would be quite useless. Thanks for your advices

Translate
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
LEGEND ,
Feb 29, 2016 Feb 29, 2016

Importing audio into the library doesn't make it play.

Translate
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
New Here ,
Feb 29, 2016 Feb 29, 2016

as you can see there is the down (the yellow one) state of the button with a keyframe and on the right the mp3 selected in the library.

Doing that i imported the audio file in the timeliine?

Screenshot 2016-02-29 22.24.45.png

Translate
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
LEGEND ,
Feb 29, 2016 Feb 29, 2016

So yes, you did place the audio on the timeline, just like I said. That Name/Nome dropdown isn't the library. The Library/Libreria tab is the library.

If you want to start and stop the sound by clicking on the same button, that's not going to work. You're going to need some code to track the button state and determine whether it should be starting or stopping the sound.

Translate
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
New Here ,
Feb 29, 2016 Feb 29, 2016
LATEST

yeah i have been able to do it with the animation of the button but not with the button. is there a code reference to see what functions i have to use to do what you said?

Translate
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