howler.js group of sounds. how?
Asked Answered
B

1

8

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?

Bortz answered 3/6, 2018 at 14:30 Comment(1)
You can't. The docs are simply falsely advertising the capabilities of the library about groups.Casual
K
0

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);
Kin answered 11/2, 2023 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.