djpaul1963
djpaul1963

Reputation: 83

howler.js group of sounds. how?

According the https://github.com/goldfire/howler.js#documentation you can pause, loop, or set the volume of a group of sounds, which is pretty useful in case of games. The question is, how do I define a group of sounds?

Upvotes: 8

Views: 666

Answers (1)

Vishwas
Vishwas

Reputation: 1541

By group they mean managing a single mp3 file containing all related sounds. For example managing a hero.mp3 file with tracks like jump, die, walk inside hero.mp3 Such files can be managed using group playback like this:

var sound = new Howl({
  src: ['hero.webm', 'hero.mp3'],
  sprite: {
    jump: [0, 10000],
    die: [11000, 15000],
    walk: [16000,18000]
  }
});

sound.play('jump');

// Change the volume of all tracks.
sound.volume(0.5);

// After a second, pause both sounds in the group.
setTimeout(function() {
  sound.pause();
sound.play('walk');
}, 1000);

Upvotes: 0

Related Questions