removeFromSoundGroup
Remove a sound from a group's member list. The sound keeps playing and stays loaded.
removeFromSoundGroup(groupName: string, soundId: string): void;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
groupName | string | required | Name of the group. |
soundId | string | required | ID of the sound or instance to take out. |
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('rain', '/audio/rain.mp3');
soundHub.createSoundGroup('ambience', { maxInstances: 2 });
soundHub.addToSoundGroup('ambience', 'rain');
soundHub.removeFromSoundGroup('ambience', 'rain');
soundHub.getGroup('ambience')?.sounds.has('rain'); // false
Good to know
- It only updates the member list. The sound is not stopped, and the group's play options that were merged into it stay.
- The sound forgets the group, so the next
playleaves it out. Before 6.4.0 it kept the link andplay()put it straight back in. - Options the group gave the sound through its
playOptionsstay on the sound. - An unknown group name does nothing apart from a debug log. An id that is not in the group is ignored.
- No event is dispatched.
See also
addToSoundGroup: put a sound in a group.removeSoundGroup: stop every member and delete the group.getGroup: see which sounds a group holds.