Skip to content

AudioManagerPlugin

Defined in: plugins/audio/AudioManagerPlugin.ts:89

AudioManager is a class that manages audio playback in the application. It provides methods to play, stop, fade in/out, and crossfade sounds. It also allows you to create and manage audio channels.

Example

const audioManager = new AudioManager();
audioManager.play('soundId', 'music');

Extends

Type Parameters

C extends ChannelName = ChannelName

Implements

Constructors

new AudioManagerPlugin()

new AudioManagerPlugin<C>(id): AudioManagerPlugin<C>

Defined in: plugins/audio/AudioManagerPlugin.ts:133

Creates a new AudioManager instance.

Parameters

id

string = 'audio'

The ID of the AudioManager. Default is ‘AudioManager’.

Returns

AudioManagerPlugin<C>

Overrides

Plugin.constructor

Properties

__dill_pixel_method_binding_root

__dill_pixel_method_binding_root: boolean

Defined in: plugins/Plugin.ts:37

Inherited from

Plugin.__dill_pixel_method_binding_root


id

id: string = 'Plugin'

Defined in: plugins/Plugin.ts:40

Implementation of

IAudioManagerPlugin.id

Inherited from

Plugin.id


onChannelMuted

onChannelMuted: Signal<(detail) => void>

Defined in: plugins/audio/AudioManagerPlugin.ts:121

Signal that is emitted when a channel is muted or unmuted. The callback function receives a ChannelMutedDetail object.

Implementation of

IAudioManagerPlugin.onChannelMuted


onChannelVolumeChanged

onChannelVolumeChanged: Signal<(detail) => void>

Defined in: plugins/audio/AudioManagerPlugin.ts:114

Signal that is emitted when a channel’s volume changes. The callback function receives a ChannelVolumeDetail object.

Implementation of

IAudioManagerPlugin.onChannelVolumeChanged


onMasterVolumeChanged

onMasterVolumeChanged: Signal<(volume) => void>

Defined in: plugins/audio/AudioManagerPlugin.ts:109

Signal that is emitted when the master volume changes. The callback function receives the new volume as a number.

Implementation of

IAudioManagerPlugin.onMasterVolumeChanged


onMuted

onMuted: Signal<(muted) => void>

Defined in: plugins/audio/AudioManagerPlugin.ts:104

Signal that is emitted when the system is muted or unmuted.

Implementation of

IAudioManagerPlugin.onMuted


onSoundEnded

onSoundEnded: Signal<(detail) => void>

Defined in: plugins/audio/AudioManagerPlugin.ts:100

Signal that is emitted when a sound ends. The callback function receives a SoundDetail object.

Implementation of

IAudioManagerPlugin.onSoundEnded


onSoundStarted

onSoundStarted: Signal<(detail) => void>

Defined in: plugins/audio/AudioManagerPlugin.ts:95

Signal that is emitted when a sound starts playing. The callback function receives a SoundDetail object.

Implementation of

IAudioManagerPlugin.onSoundStarted

Accessors

app

Get Signature

get app(): T

Defined in: plugins/Plugin.ts:45

Returns

T

Implementation of

IAudioManagerPlugin.app

Inherited from

Plugin.app


channels

Get Signature

get channels(): Map<string, IAudioChannel>

Defined in: plugins/audio/AudioManagerPlugin.ts:185

Gets the map of audio channels.

Returns

Map<string, IAudioChannel>

The map of audio channels.

Implementation of

IAudioManagerPlugin.channels


masterVolume

Get Signature

get masterVolume(): number

Defined in: plugins/audio/AudioManagerPlugin.ts:147

Gets the master volume.

Returns

number

The master volume.

Set Signature

set masterVolume(value): void

Defined in: plugins/audio/AudioManagerPlugin.ts:155

Sets the master volume.

Parameters
value

number

The new master volume.

Returns

void

Implementation of

IAudioManagerPlugin.masterVolume


music

Get Signature

get music(): IAudioChannel

Defined in: plugins/audio/AudioManagerPlugin.ts:189

Returns

IAudioChannel

Implementation of

IAudioManagerPlugin.music


muted

Get Signature

get muted(): boolean

Defined in: plugins/audio/AudioManagerPlugin.ts:166

Gets whether the audio is muted.

Returns

boolean

True if the audio is muted, false otherwise.

Set Signature

set muted(value): void

Defined in: plugins/audio/AudioManagerPlugin.ts:174

Sets whether the audio is muted.

Parameters
value

boolean

True to mute the audio, false to unmute.

Returns

void

Implementation of

IAudioManagerPlugin.muted


sfx

Get Signature

get sfx(): IAudioChannel

Defined in: plugins/audio/AudioManagerPlugin.ts:193

Returns

IAudioChannel

Implementation of

IAudioManagerPlugin.sfx


vo

Get Signature

get vo(): IAudioChannel

Defined in: plugins/audio/AudioManagerPlugin.ts:201

Returns

IAudioChannel

Implementation of

IAudioManagerPlugin.vo


voiceover

Get Signature

get voiceover(): IAudioChannel

Defined in: plugins/audio/AudioManagerPlugin.ts:197

Returns

IAudioChannel

Implementation of

IAudioManagerPlugin.voiceover

Methods

add()

add(soundAsset): void

Defined in: plugins/audio/AudioManagerPlugin.ts:343

Adds a sound asset to the AudioManager.

Parameters

soundAsset

UnresolvedAsset

Returns

void

Implementation of

IAudioManagerPlugin.add


addAllFromBundle()

addAllFromBundle(bundleName, manifest?): void

Defined in: plugins/audio/AudioManagerPlugin.ts:312

Adds all sound assets from the specified bundle.

Parameters

bundleName

string

manifest?

string | AssetsManifest

Returns

void

Implementation of

IAudioManagerPlugin.addAllFromBundle


addAllFromManifest()

addAllFromManifest(manifest): void

Defined in: plugins/audio/AudioManagerPlugin.ts:301

Adds all sound assets from the specified manifest.

Parameters

manifest

AssetsManifest

Returns

void

Implementation of

IAudioManagerPlugin.addAllFromManifest


addSignalConnection()

addSignalConnection(…args): void

Defined in: plugins/Plugin.ts:71

Add signal connections to the container.

Parameters

args

SignalConnection[]

The signal connections to add.

Returns

void

Implementation of

IAudioManagerPlugin.addSignalConnection

Inherited from

Plugin.addSignalConnection


clearSignalConnections()

clearSignalConnections(): void

Defined in: plugins/Plugin.ts:77

Returns

void

Implementation of

IAudioManagerPlugin.clearSignalConnections

Inherited from

Plugin.clearSignalConnections


createChannel()

createChannel(name): void

Defined in: plugins/audio/AudioManagerPlugin.ts:236

Creates a new audio channel.

Parameters

name

string

Returns

void

Implementation of

IAudioManagerPlugin.createChannel


crossFade()

crossFade(outSoundId, inSoundId, channelName, duration): Promise<null | Tween>

Defined in: plugins/audio/AudioManagerPlugin.ts:480

Crossfades between two sounds in the specified channel.

Parameters

outSoundId

string

inSoundId

string

channelName

ChannelName = 'music'

duration

number = 2

Returns

Promise<null | Tween>

Implementation of

IAudioManagerPlugin.crossFade


destroy()

destroy(): void

Defined in: plugins/audio/AudioManagerPlugin.ts:205

Returns

void

Implementation of

IAudioManagerPlugin.destroy

Overrides

Plugin.destroy


fade()

fade(soundId, channelName, props, stopOnComplete): Promise<null | Tween>

Defined in: plugins/audio/AudioManagerPlugin.ts:499

Fades a sound with the specified ID in the specified channel.

Parameters

soundId

string

channelName

ChannelName = 'music'

props

TweenVars

stopOnComplete

boolean = false

Returns

Promise<null | Tween>

Implementation of

IAudioManagerPlugin.fade


fadeIn()

fadeIn(soundId, channelName, props): Promise<null | Tween>

Defined in: plugins/audio/AudioManagerPlugin.ts:428

Fades in a sound with the specified ID in the specified channel.

Parameters

soundId

string

channelName

C = ...

props

TweenVars

Returns

Promise<null | Tween>

Implementation of

IAudioManagerPlugin.fadeIn


fadeOut()

fadeOut(soundId, channelName, props): Promise<null | Tween>

Defined in: plugins/audio/AudioManagerPlugin.ts:454

Fades out a sound with the specified ID in the specified channel.

Parameters

soundId

string

channelName

C = ...

props

Partial<TweenVars> = ...

Returns

Promise<null | Tween>

Implementation of

IAudioManagerPlugin.fadeOut


getAudioInstance()

getAudioInstance(soundId, channelName): undefined | IAudioInstance

Defined in: plugins/audio/AudioManagerPlugin.ts:550

Parameters

soundId

string

channelName

C = ...

Returns

undefined | IAudioInstance

Implementation of

IAudioManagerPlugin.getAudioInstance


getChannel()

getChannel(name): undefined | IAudioChannel

Defined in: plugins/audio/AudioManagerPlugin.ts:261

Gets the audio channel with the specified name.

Parameters

name

C

Returns

undefined | IAudioChannel

Implementation of

IAudioManagerPlugin.getChannel


initialize()

initialize(app): Promise<void>

Defined in: plugins/audio/AudioManagerPlugin.ts:224

Initializes the AudioManager.

Parameters

app

IApplication

Returns

Promise<void>

Implementation of

IAudioManagerPlugin.initialize

Overrides

Plugin.initialize


isPlaying()

isPlaying(soundId, channelName): boolean

Defined in: plugins/audio/AudioManagerPlugin.ts:361

Parameters

soundId

string

channelName

C

Returns

boolean

Implementation of

IAudioManagerPlugin.isPlaying


load()

load(soundId, channelName, options?): void

Defined in: plugins/audio/AudioManagerPlugin.ts:560

Parameters

soundId

string | string[]

channelName

C = ...

options?

PlayOptions

Returns

void

Implementation of

IAudioManagerPlugin.load


mute()

mute(): void

Defined in: plugins/audio/AudioManagerPlugin.ts:268

Mutes the audio.

Returns

void

Implementation of

IAudioManagerPlugin.mute


pause()

pause(): void

Defined in: plugins/audio/AudioManagerPlugin.ts:284

Pauses the audio.

Returns

void

Implementation of

IAudioManagerPlugin.pause


play()

play(soundId, channelName, options?): Promise<IAudioInstance>

Defined in: plugins/audio/AudioManagerPlugin.ts:376

Plays a sound with the specified ID in the specified channel.

Parameters

soundId

string

channelName

C = ...

options?

PlayOptions

Returns

Promise<IAudioInstance>

Implementation of

IAudioManagerPlugin.play


postInitialize()

postInitialize(_app): void | Promise<void>

Defined in: plugins/Plugin.ts:60

Parameters

_app

IApplication

Returns

void | Promise<void>

Implementation of

IAudioManagerPlugin.postInitialize

Inherited from

Plugin.postInitialize


restore()

restore(): Promise<void>

Defined in: plugins/audio/AudioManagerPlugin.ts:525

Restores the audio state after it has been suspended.

Returns

Promise<void>

Implementation of

IAudioManagerPlugin.restore


resume()

resume(): void

Defined in: plugins/audio/AudioManagerPlugin.ts:292

Resumes the audio.

Returns

void

Implementation of

IAudioManagerPlugin.resume


setChannelVolume()

setChannelVolume(channelName, volume): void

Defined in: plugins/audio/AudioManagerPlugin.ts:249

Sets the volume of the specified channel.

Parameters

channelName

C | C[]

volume

number

Returns

void

Implementation of

IAudioManagerPlugin.setChannelVolume


stop()

stop(soundId, channelName): undefined | IAudioInstance

Defined in: plugins/audio/AudioManagerPlugin.ts:412

Stops a sound with the specified ID in the specified channel.

Parameters

soundId

string

channelName

C = ...

Returns

undefined | IAudioInstance

Implementation of

IAudioManagerPlugin.stop


stopAll()

stopAll(fade, duration, props): void

Defined in: plugins/audio/AudioManagerPlugin.ts:583

Parameters

fade

boolean = false

duration

number = 1

props

TweenVars = {}

Returns

void

Implementation of

IAudioManagerPlugin.stopAll


suspend()

suspend(): void

Defined in: plugins/audio/AudioManagerPlugin.ts:544

Suspends the audio by setting the master volume to 0 and pausing all sounds.

Returns

void

Implementation of

IAudioManagerPlugin.suspend


unmute()

unmute(): void

Defined in: plugins/audio/AudioManagerPlugin.ts:276

Unmutes the audio.

Returns

void

Implementation of

IAudioManagerPlugin.unmute