Copy link to clipboard
Copied
I'm publishing my animate file as Javasript/HTML and have the code below. How would I amend this to allow my sound file to loop? Everything plays at the moment apart from looping. Thanks.
_main = this;
this.stop();
createjs.Sound.on("fileload", handleFileLoad);
createjs.Sound.registerSound("sounds/soundtrack.mp3", "MySound");
function handleFileLoad()
{
_main.audio1 = createjs.Sound.play("MySound");
_main.play();
}
Hey floras,
Please try the below code which I got from GIT and has worked for me too.
createjs.Sound.on("fileload", handleLoad);
createjs.Sound.registerSound("sounds/youraudio.mp3", "myID", 3);
function handleLoad(event) {
createjs.Sound.play("myID");
// store off AbstractSoundInstance for controlling
var myInstance = createjs.Sound.play("myID", {interrupt: createjs.Sound.INTERRUPT_ANY, loop:-1});
}
I am also just a beginner in Js coding and hopefully it should work for you also.
Thanks!
Ankush
Copy link to clipboard
Copied
Hey floras,
Please try the below code which I got from GIT and has worked for me too.
createjs.Sound.on("fileload", handleLoad);
createjs.Sound.registerSound("sounds/youraudio.mp3", "myID", 3);
function handleLoad(event) {
createjs.Sound.play("myID");
// store off AbstractSoundInstance for controlling
var myInstance = createjs.Sound.play("myID", {interrupt: createjs.Sound.INTERRUPT_ANY, loop:-1});
}
I am also just a beginner in Js coding and hopefully it should work for you also.
Thanks!
Ankush
Copy link to clipboard
Copied
This seems to have worked. Many thanks!
Copy link to clipboard
Copied
This is what I use which is compact.
this.myMusic = createjs.Sound.play("music", "none", 0, 0, -1, 0.5);
//
music is the instance name
"none' is the interrupt
0 is delay
0 is offset
-1 is loop 0 is no loop
0.5 is the volume