Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

410
Vistas
How to stop/play a sound loop in Animate CC HTML5 Canvas?

I managed to make the sound loop start when the frame loads using this code:

createjs.Sound.on("fileload", handleLoad);
createjs.Sound.alternateExtensions = ["m4a"];
createjs.Sound.registerSound({
    id: "audioLoop",
    src: "sounds/myAudioLoop.ogg"
});
function handleLoad(event) {
    var audioLoopInstance = createjs.Sound.play("audioLoop", {
        interrupt: createjs.Sound.INTERRUPT_ANY,
        loop: -1
    });
};

When I try audioLoopInstance.stop(); or audioLoopInstance.play(); though, nothing seem to happen.

The stop all sounds seem to work, although I don't know how to play it again after that:

stopEverySounds = function () {
    return createjs.Sound.stop();
}

stopEverySounds();

I am trying to learn to use the sound instance thing. How do I make audioLoopInstance to start the sound again?


Update: Seems I have to define the var in my original code like this:

var _this = this;

function handleLoad(event) {
    _this.audioLoopInstance = createjs.Sound.play("audioLoop", {
        interrupt: createjs.Sound.INTERRUPT_ANY,
        loop: -1
    });
};

And then I'll be able to use that sound instance.

If stop/play code is in same frame:

_this.audioLoopInstance.stop();

If stop/play code is in different frame in the same timeline:

this.audioLoopInstance.play();
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda