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

How do I play a sound using SoundJS in HTML Canvas?

Community Beginner ,
Nov 29, 2018 Nov 29, 2018

I've tried a million things and can't get this sound to play either from the "test" menu item or from a local server.

I have previewed the sound in Animate and it plays, it's a 128kb MP3, and I've tried on Mac Safari, Chrome, and Firefox. Still, I get no sound.

I'm sure it's something simple... first time trying to do this... help is much appreciated!

My Code:

createjs.Sound.on("fileload", handleLoad); 

createjs.Sound.registerSound("sounds/discoSong.mp3", "myID", 3);

function handleLoad(event) {

  createjs.Sound.play("myID"); 

  var myInstance = createjs.Sound.play("myID");

  console.log(myInstance);

}

The output from that console.log:

a {_listeners: null, _captureListeners: null, src: "sounds/discoSong.mp3", uniqueId: 1, playState: "playSucceeded", …}

"playSucceeded"... I think not!

Thanks!

1.5K
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 Beginner , Dec 05, 2018 Dec 05, 2018

Problem solved, new computer, browser was blocking autoplay. Thanks for the help! How do I mark this discussion as closed?

Translate
LEGEND ,
Nov 29, 2018 Nov 29, 2018

For example:

  • You need to add a linkage name for your sound file in the library.
  • this.incorrect = createjs.Sound.play("incorrect", "none", 0, 0, 0, 0.6);

incorrect: this is the linkage name

  • this.incorrect.paused = true;   (it stops)
  • this.incorrect.paused = false;   (it plays)
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 ,
Nov 29, 2018 Nov 29, 2018

Explanation

this.incorrect = createjs.Sound.play("incorrect", "none", 0, 0, 0, 0.6);

this.incorrect = createjs.Sound.play("linkagename", "interrupt", delay, offset, loop, volume);

Of course you may be importing the sound to the stage which is a different story.

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 ,
Nov 29, 2018 Nov 29, 2018

this.discoSong = createjs.Sound.play("discoSong", "none", 0, 0, 0, 0.6 );

Screen Shot 2018-11-29 at 3.40.45 PM.png

Linkage is set, I'm still getting nothing.

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
Adobe Employee ,
Dec 03, 2018 Dec 03, 2018

Does this happen with all your files?

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 03, 2018 Dec 03, 2018

I've only tried two, and both play in the browser. Are there further format restrictions in Animate? What format should I try?

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 05, 2018 Dec 05, 2018

Problem solved, new computer, browser was blocking autoplay. Thanks for the help! How do I mark this discussion as closed?

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 ,
Dec 05, 2018 Dec 05, 2018

Awesome!!!

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 ,
Dec 05, 2018 Dec 05, 2018

If you mark it as correct it will be closed somewhat. People can still see it and it is useful for searches.

Good luck on your project!

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 ,
Nov 07, 2023 Nov 07, 2023

I am a new to html5. I'm using Adobe Animate to convert some FLA files to html5. Foe my first conversion, upon entering the page, background music should automatically play. The song that should be called is "Photos.mp3". The song is located in a subdirectory called "sounds" which exists in the same directory as my html file. The mp3 file does not play, I was going to attach my code, but I don't see a way to do that here.

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 ,
Nov 07, 2023 Nov 07, 2023

I'm the original poster. I'm not sure how I ended up posting on a friend's account. I just wanted to add something: if I allow the page to keep looping, eventually at least part of the mp3 file will 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
Community Expert ,
Nov 07, 2023 Nov 07, 2023

user interaction must occur before browsers will allow sound to 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 ,
Nov 08, 2023 Nov 08, 2023

Drat. I was fearing that. Thank you.

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 ,
Nov 08, 2023 Nov 08, 2023
LATEST

you're welcome.

 

just put into design/text in frame 1 with a click here to proceed to you site. then advance to frame 2 and start your 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
LEGEND ,
Dec 05, 2018 Dec 05, 2018

Accepted Answer: Replace your computer.

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