createSoundGroup
createSoundGroup(groupName: string, options?: { maxInstances?: number; playOptions?: PlayOptions }): void;
Group management: Create and manage sound groups to control multiple sounds collectively.
Creates a new sound group with the given name and optional configuration. Groups allow you to control multiple sounds collectively, such as limiting the number of simultaneous instances or applying shared playback options.
| Parameter | Type | Description |
|---|---|---|
groupName | string | Name of the group to create |
options | { maxInstances?: number; playOptions?: PlayOptions } (optional) | Configuration for the group |
Options
| Property | Type | Description |
|---|---|---|
maxInstances | number (optional) | Maximum number of sounds that can play simultaneously within this group |
playOptions | PlayOptions (optional) | Default playback options applied to all sounds in the group |
Example
import { SoundManager } from 'sound-manager-ts';
const soundManager = new SoundManager();
// Create a group that limits to 3 simultaneous sounds
soundManager.createSoundGroup('effects', {
maxInstances: 3,
playOptions: { volume: 0.5 }
});