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

How to do i loop my sound in javascript/html output?

New Here ,
Jul 20, 2018 Jul 20, 2018

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(); 

}

Views

3.9K

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

correct answers 1 Correct answer

Jul 20, 2018 Jul 20, 2018

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

Votes

Translate

Translate
Jul 20, 2018 Jul 20, 2018

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

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
New Here ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

This seems to have worked. Many thanks!

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 ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

LATEST

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

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