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.
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
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
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).
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.
Copy link to clipboard
Copied
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).