UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

190 lines (88 loc) 3.13 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [AudioManager](./server.audiomanager.md) ## AudioManager class Manages audio instances in a world. When to use: querying or bulk-controlling audio in a specific world. Do NOT use for: individual playback configuration; use `Audio` instances. **Signature:** ```typescript export default class AudioManager ``` ## Remarks The AudioManager is created internally per `World` instance. Audio is loaded on first `Audio.play`<!-- -->; this manager tracks loaded instances. Pattern: call `AudioManager.unregisterEntityAttachedAudios` when despawning entities with positional audio. The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `AudioManager` class. ## Example ```typescript // Stop all audio in the world const audioManager = world.audioManager; audioManager.getAllAudios().forEach(audio => audio.pause()); ``` \*\*Category:\*\* Audio ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [world](./server.audiomanager.world.md) </td><td> `readonly` </td><td> [World](./server.world.md) </td><td> The world the audio manager is for. \*\*Category:\*\* Audio </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [getAllAudios()](./server.audiomanager.getallaudios.md) </td><td> </td><td> Retrieves all loaded audio instances for the world. </td></tr> <tr><td> [getAllEntityAttachedAudios(entity)](./server.audiomanager.getallentityattachedaudios.md) </td><td> </td><td> Retrieves all loaded audio instances attached to a specific entity. Use for: cleanup when despawning an entity with positional audio. </td></tr> <tr><td> [getAllLoopedAudios()](./server.audiomanager.getallloopedaudios.md) </td><td> </td><td> Retrieves all looped audio instances for the world. </td></tr> <tr><td> [getAllOneshotAudios()](./server.audiomanager.getalloneshotaudios.md) </td><td> </td><td> Retrieves all oneshot (non-looped) audio instances for the world. </td></tr> <tr><td> [unregisterAudio(audio)](./server.audiomanager.unregisteraudio.md) </td><td> </td><td> Unregisters and stops an audio instance from the audio manager. Use for: explicit cleanup of one-shot or temporary sounds. Do NOT use for: pausing/resuming; use `Audio.pause` or `Audio.play` instead. </td></tr> <tr><td> [unregisterEntityAttachedAudios(entity)](./server.audiomanager.unregisterentityattachedaudios.md) </td><td> </td><td> Unregisters and stops all audio instances attached to a specific entity. Use for: entity despawn or cleanup scenarios. </td></tr> </tbody></table>