Copy link to clipboard
Copied
I have made an animation of an image in html5 canvas in animate cc. Then I add an mp3 song in a frame with this code:
createjs.Sound.on("fileload", handleLoad);
createjs.Sound.registerSound("xxx.mp3", "bgmLoop");
function handleLoad(event) {
createjs.Sound.play("bgmLoop");
}
In microsoft edge, the sound works but the image is still white no image view.
When I remove the code in .fla for canvas, the image of the animation in canvas appears.
How to use create.js for seamless background music? This person has the same problem as me with the code.
For me, I don't work both in Chrome or Android.
What is the problem in the HTML 5 animate CC program.
Can anyone solve it so that it works with background music in my animation.
you can‘t. read the chrome info.
Copy link to clipboard
Copied
there's nothing wrong with your code but open your console to see the problem.
Copy link to clipboard
Copied
// create global alias to main timeline for event handler
// wait for sound to preload
// assign load event handler
createjs.Sound.on("fileload", handleLoad);
// load and register sound
createjs.Sound.registerSound("sacred.mp3", "soundID");
// play sound and start timeline playing
function handleLoad(event) {
createjs.Sound.play("soundID");
}
I use this code in frame 1 in file musikprov.fla html5 canvas and in Microsoft Edge browser so works it but in Android os in smartphone and Chrome so don't works it.
I have read this WebAudio Plugin and CreateJS broken in new Chrome Update and there it stands "the policy will be re-applied to the Web Audio API in Chrome 70 (October)". Is it the browser error both in Android and Iphone Apple IOS with code.createjs.com Sound.
Copy link to clipboard
Copied
you need to use a click event or some other user interaction for chrome to trigger the play() method.
Copy link to clipboard
Copied
Can you show me this.
Copy link to clipboard
Copied
this.your_button.addEventListener('click',playF.bind(this));
function playF(){
createjs.Sound.play("soundID");
}
// load and register sound
createjs.Sound.registerSound("sacred.mp3", "soundID");
Copy link to clipboard
Copied
Yes this works in my Chrome browser. But I want to use sound then I come into the frame in begin without button or can I not to do it.
Copy link to clipboard
Copied
you can‘t. read the chrome info.
Copy link to clipboard
Copied
how to know that the audio is over?
Copy link to clipboard
Copied
use a "complete" listener.
this.your_button.addEventListener('click',playF.bind(this));
function playF(){
var sound_instance = createjs.Sound.play("soundID");
sound_instance.addEventListener("complete",completeF.bind(this));
}
function completeF(){
// sound completed play
}
// load and register sound
createjs.Sound.registerSound("sacred.mp3", "soundID");