the documentation mentions groups but does not show how to define them
it would be nice to get an example on groups added.
Apparently a group is an instance of HowlerGlobal but only one instance of it is created and there isn't any way to change the current instance to have multiple groups. Its local variable is called "Howler" but it's only assigned once and should not be confused with the module's exported property "Howler"
When a Howl is created, it uses the local Howler's _howls array. There is no apparent way to change any of this unless you modify the code yourself.
ahm.. that is a bit hard to understand...
i only understood, that i cant create some howls and assign them to a group id.
to play pause fade etc. the group id instead of each individual sound...
the existing documentation sounds a bit like this would come out of the box
best, steve
On 29.06.2018, at 22:53, Jesse O notifications@github.com wrote:
Apparently a group is an instance of HowlerGlobal but only one instance of it is created and there isn't any way to change the current instance to have multiple groups. Its local variable is called "Howler" but it's only assigned once and should not be confused with the module's exported property "Howler"
When a Howl is created, it uses the local Howler's _howls array. There is no apparent way to change any of this unless you modify the code yourself.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/goldfire/howler.js/issues/982#issuecomment-401471136, or mute the thread https://github.com/notifications/unsubscribe-auth/AYq3mhZMV3ZRCgRfbVJ6dqeVLkjq0-UKks5uBpO8gaJpZM4U68Sg.
After searching the code, I can only guess that they're a feature that's in the works still. If you want to manipulate multiple sounds at once, you'll have to define your own arrays of Howls. Maybe the author @goldfire knows.
For those who needs to figure out a way to achieve this, here's my simple way, you can do different sound groups by creating arrays with the variable names of the sounds like:
var sound1 = new Howl({ src: ['/folder/of/myaudio.mp3']});
var sound2 = ne..........
var ambientVolume = [ sound1, sound2, sound3, sound4 ]
var effectsVolume = [ sound5, sound6, sound7 ]
var musicVolume = [ sound8 ]
Then just simply use those array names to change the volume of each existing entities, like
for (var i = 0; i < ambientVolume.length; i++) { //For each sound in ambientVolume array
ambientVolume[i].volume(0); //Change the volume to 0
}
_Note that you don't need to specify the mainVolume, use howler.volume(number) to change every sound instead_
_Also, i think that a "howler group" is really referencing the multiple instances of a very same sound (_when you play the same sound multiple times, each one having a unique id to handle them_)_
_When you need to control that whole group then don't specify the id sound1.mute(true); otherwise being sound1.mute(true,id);_
And you got it! :smile:
Shouldn't the main docs be updated to explain that groups don't work currently? The main page for the repo has 22 references to groups in the API description. A small note at the top of the main readme would save people a lot of head scratching. Fortunately I found this issue quickly when I searched for "howlerjs groups". Other people might not be so lucky.
HowlerJS is great either way.
I've had exactly the same problem, because I thought I can use Howler to group different sound in groups, eg putting hello.mp3 and hi.mp3 to the group "greetings" and goodby.mp3 and bye.mp3 to the group farewell. But that's not the understanding of goups in Howler.
So I think @Boscox is right with the explanation of multiple instances!
I'm new to Howler and I'm also looking for a way to play/pause/stop tracks in sync, the docs explicitly mention "Control sounds individually, in groups or globally" as a feature so I'm looking for a native way to do so but as I understand from this open issue this is not possible. I'm confused 😅
Most helpful comment
For those who needs to figure out a way to achieve this, here's my simple way, you can do different sound groups by creating arrays with the variable names of the sounds like:
Then just simply use those array names to change the volume of each existing entities, like
_Note that you don't need to specify the mainVolume, use
howler.volume(number)to change every sound instead__Also, i think that a "howler group" is really referencing the multiple instances of a very same sound (_when you play the same sound multiple times, each one having a unique id to handle them_)_
_When you need to control that whole group then don't specify the id
sound1.mute(true);otherwise beingsound1.mute(true,id);_And you got it! :smile: