Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

How to make an text speech or button to play another audio

Community Beginner ,
Dec 01, 2024 Dec 01, 2024

I'm making an interactive media using html5 in adobe animate 

I want to create a button that can play an audio for textspeech, so when pressed it will play the audio.
But I also want that when pressed once again the audio will be turned off

for the button to start it is already running, but for the button to turn it off in addition to the textspeech audio stopped my interactive media music backsound also stopped.

How do I stop the audio speech without turning off the audio backsound?


or are there any suggestions on how to make a textspeech or button that can be used to play the textspeech audio?

Here my code 

Phantommlunatic_0-1733121624567.png

I'm using a movieclip with 2 button, here code when clicking and play the text speech

Phantommlunatic_1-1733121685111.png

and here  the button to turn off the audio, but the backsound also stopped

Phantommlunatic_2-1733121916652.png

because have a separate button to disable the music backsound.



TOPICS
Code , How to
294
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

correct answers 1 Correct answer

Community Expert , Dec 02, 2024 Dec 02, 2024

Hi.

 

Createjs.Sound.play returns an AbstractSoundInstance that you can control.

So one approach is to store these returned instances in variables or objects so that you can have multiple sounds playing.

For example:

var sfx = createjs.Sound.play("coin");
var bgm = createjs.Sound.play("level1");

// ...

yourSfxButton.on("click", function(){ sfx.stop(); });

// ...

yourBgmButton.on("click", function(){ bgm.volume = 0.5; });


This link should help as a reference:
https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/narrated_story

...
Translate
Community Expert ,
Dec 02, 2024 Dec 02, 2024

Hi.

 

Createjs.Sound.play returns an AbstractSoundInstance that you can control.

So one approach is to store these returned instances in variables or objects so that you can have multiple sounds playing.

For example:

var sfx = createjs.Sound.play("coin");
var bgm = createjs.Sound.play("level1");

// ...

yourSfxButton.on("click", function(){ sfx.stop(); });

// ...

yourBgmButton.on("click", function(){ bgm.volume = 0.5; });


This link should help as a reference:
https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/narrated_story

Regards,
JC

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
Community Beginner ,
Dec 07, 2024 Dec 07, 2024

@JoĆ£oCĆ©sar Thank you for the reply!
from the references you gave 

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
Community Expert ,
Dec 07, 2024 Dec 07, 2024
LATEST

You're welcome!

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