hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
179 lines (82 loc) • 2.62 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [AudioManager](./server.audiomanager.md)
## AudioManager class
Manages audio instances in a world.
**Signature:**
```typescript
export default class AudioManager
```
## Remarks
The AudioManager is created internally as a singleton for each [World](./server.world.md) instance in a game server. It allows retrieval of all loaded audio, entity attached audio, looped audio, and more.
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().map(audio => audio.pause());
```
## 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.
</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.
</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.
</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.
</td></tr>
</tbody></table>