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

Mp3 and createjs

Participant ,
Oct 15, 2019 Oct 15, 2019

Copy link to clipboard

Copied

I have this code in the HTML5 canvas fla document:
createjs.Sound.on("fileload", handleFileLoad);
createjs.Sound.registerSound("music1.mp3", "MySound");

function handleFileLoad()
{
createjs.Sound.play("MySound");
}
It doesn't launch in both Chrome or Android but in Microsoft Edge where it works.
In the Chrome console it says: "createjs-2015.11.26.min.js:17 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
c._generateCapabilities @ createjs-2015.11.26.min.js:17
2createjs-2015.11.26.min.js:17 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
b._createAndPlayAudioNode @ createjs-2015.11.26.min.js:17"

It has worked once with an HTML5 canvas fla document
Is the error in the createjs codes and why has it stopped working. So please help with solving this.

Views

1.2K

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
LEGEND ,
Oct 15, 2019 Oct 15, 2019

Copy link to clipboard

Copied

It's already telling you in plain English exactly what the problem is. Why are you refusing to believe it? Modern browsers don't autoplay audio unless the user has interacted with the page.

Votes

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
Participant ,
Oct 16, 2019 Oct 16, 2019

Copy link to clipboard

Copied

Why does it work in Microsoft browser Edge than Google Chrome and Android. Is it wrong in createjs. It worked when I did a slideshow but it be a few times before but not now anymore. What happened. I want to be able to play an mp3 song without having a button that starts it.

Votes

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
Participant ,
Oct 16, 2019 Oct 16, 2019

Copy link to clipboard

Copied

Have tested and tried so now it works. So now I have solved the problem. It now works in the Chrome browser.

Votes

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
LEGEND ,
Oct 17, 2019 Oct 17, 2019

Copy link to clipboard

Copied

If it's working it's because you clicked somewhere on the page before your code tried to play the sound, OR if you're testing on a web server, you've trained your Chrome install to play the audio by raising the page's engagement index. If the latter, then it will still have problems for other users.

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

 

As for Edge, it works in Edge because Edge is not a modern browser. Microsoft has abandoned the current version of Edge and is working on a completely new version based on Chromium.

Votes

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
Participant ,
Oct 18, 2019 Oct 18, 2019

Copy link to clipboard

Copied

What should I do to make it work in Android and Chrome when using Animate CC with HTML5 canvas. Can you show me what code sets and how to go about it. Does it matter if I use mp3 or ogg

Votes

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
LEGEND ,
Oct 18, 2019 Oct 18, 2019

Copy link to clipboard

Copied

You aren't listening. Let me try one more time.

 

Modern browsers don't autoplay audio unless the user has interacted with the page (or the page is YouTube or the user has already interacted with the page some number of times in the past).

Votes

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
Participant ,
Oct 19, 2019 Oct 19, 2019

Copy link to clipboard

Copied

This is how it is. I have done a slide show with 52 pictures of me where I have lots of frames in Animate CC 2019 where in the library I have png, graphics and MovieClip. Then I'll convert a symbol graphic of png or to MovieClip or to button. Then give an instance name to MovieClip or button that I have done and I have also added some labels to some frames. In the label "begin" of the frame before frame I have

this.stop();
this.starta.addEventListener("click", playClicked.bind(this));

function playClicked() {
createjs.Sound.play("soundID");
this.play("begin");
}

// load and register sound   
createjs.Sound.registerSound("music1.mp3", "soundID");

This doesn't work but when I change or remove png and use a circle or square rectangle shape it convert a symbol to MovieClip then it start to play and even the sound of mp3 works in browser Chrome. I haven't tested in Android yet but I thinks it's works there also.

Votes

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
Explorer ,
Aug 27, 2021 Aug 27, 2021

Copy link to clipboard

Copied

LATEST

Hi peor,

I experienced too the case you explained. Very kind ClayUUID said enough to describe the reason for mentioned "error" in Chrome. If you need some sound to execute like some kind of "autoplay" then a user must click anywhere on screen and then it works. Probably there is some way to achieve it by "simulate" mouse click on the screen before call sound to play but I didn't try it (yet).

Votes

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