AudioManagerPlugin
Defined in: plugins/audio/AudioManagerPlugin.ts:131
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
Section titled “Example”const audioManager = new AudioManager();audioManager.play('soundId', 'music');
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”C
extends ChannelName
= ChannelName
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AudioManagerPlugin<
C
>(id
):AudioManagerPlugin
<C
>
Defined in: plugins/audio/AudioManagerPlugin.ts:175
Creates a new AudioManager instance.
Parameters
Section titled “Parameters”string
= 'audio'
The ID of the AudioManager. Default is ‘AudioManager’.
Returns
Section titled “Returns”AudioManagerPlugin
<C
>
Overrides
Section titled “Overrides”Properties
Section titled “Properties”id:
string
='Plugin'
Defined in: plugins/Plugin.ts:48
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”onChannelMuted
Section titled “onChannelMuted”onChannelMuted:
Signal
<(detail
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:163
Signal that is emitted when a channel is muted or unmuted. The callback function receives a ChannelMutedDetail object.
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.onChannelMuted
onChannelVolumeChanged
Section titled “onChannelVolumeChanged”onChannelVolumeChanged:
Signal
<(detail
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:156
Signal that is emitted when a channel’s volume changes. The callback function receives a ChannelVolumeDetail object.
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.onChannelVolumeChanged
onMasterVolumeChanged
Section titled “onMasterVolumeChanged”onMasterVolumeChanged:
Signal
<(volume
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:151
Signal that is emitted when the master volume changes. The callback function receives the new volume as a number.
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.onMasterVolumeChanged
onMuted
Section titled “onMuted”onMuted:
Signal
<(muted
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:146
Signal that is emitted when the system is muted or unmuted.
Implementation of
Section titled “Implementation of”onSoundEnded
Section titled “onSoundEnded”onSoundEnded:
Signal
<(detail
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:142
Signal that is emitted when a sound ends. The callback function receives a SoundDetail object.
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.onSoundEnded
onSoundStarted
Section titled “onSoundStarted”onSoundStarted:
Signal
<(detail
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:137
Signal that is emitted when a sound starts playing. The callback function receives a SoundDetail object.
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.onSoundStarted
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get app():
Application
Defined in: plugins/Plugin.ts:52
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”channels
Section titled “channels”Get Signature
Section titled “Get Signature”get channels():
Map
<string
,IAudioChannel
>
Defined in: plugins/audio/AudioManagerPlugin.ts:227
Gets the map of audio channels.
Returns
Section titled “Returns”Map
<string
, IAudioChannel
>
The map of audio channels.
Implementation of
Section titled “Implementation of”masterVolume
Section titled “masterVolume”Get Signature
Section titled “Get Signature”get masterVolume():
number
Defined in: plugins/audio/AudioManagerPlugin.ts:189
Gets the master volume.
Returns
Section titled “Returns”number
The master volume.
Set Signature
Section titled “Set Signature”set masterVolume(
value
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:197
Sets the master volume.
Parameters
Section titled “Parameters”number
The new master volume.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.masterVolume
Get Signature
Section titled “Get Signature”get music():
IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:231
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”Get Signature
Section titled “Get Signature”get muted():
boolean
Defined in: plugins/audio/AudioManagerPlugin.ts:208
Gets whether the audio is muted.
Returns
Section titled “Returns”boolean
True if the audio is muted, false otherwise.
Set Signature
Section titled “Set Signature”set muted(
value
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:216
Sets whether the audio is muted.
Parameters
Section titled “Parameters”boolean
True to mute the audio, false to unmute.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”options
Section titled “options”Get Signature
Section titled “Get Signature”get options():
O
Defined in: plugins/Plugin.ts:44
Returns
Section titled “Returns”O
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”paused
Section titled “paused”Get Signature
Section titled “Get Signature”get paused():
boolean
Defined in: plugins/audio/AudioManagerPlugin.ts:340
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”Get Signature
Section titled “Get Signature”get sfx():
IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:235
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”Get Signature
Section titled “Get Signature”get vo():
IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:243
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”voiceover
Section titled “voiceover”Get Signature
Section titled “Get Signature”get voiceover():
IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:239
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”add(
soundAsset
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:403
Adds a sound asset to the AudioManager.
Parameters
Section titled “Parameters”soundAsset
Section titled “soundAsset”UnresolvedAsset
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”addAllFromBundle()
Section titled “addAllFromBundle()”addAllFromBundle(
bundleName
,manifest?
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:371
Adds all sound assets from the specified bundle.
Parameters
Section titled “Parameters”bundleName
Section titled “bundleName”string
manifest?
Section titled “manifest?”string
| AssetsManifest
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.addAllFromBundle
addAllFromManifest()
Section titled “addAllFromManifest()”addAllFromManifest(
manifest
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:348
Adds all sound assets from the specified manifest.
Parameters
Section titled “Parameters”manifest
Section titled “manifest”AssetsManifest
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.addAllFromManifest
addSignalConnection()
Section titled “addSignalConnection()”addSignalConnection(…
args
):void
Defined in: plugins/Plugin.ts:78
Add signal connections to the container.
Parameters
Section titled “Parameters”…SignalConnection
[]
The signal connections to add.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.addSignalConnection
Inherited from
Section titled “Inherited from”clearSignalConnections()
Section titled “clearSignalConnections()”clearSignalConnections():
void
Defined in: plugins/Plugin.ts:84
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.clearSignalConnections
Inherited from
Section titled “Inherited from”createChannel()
Section titled “createChannel()”createChannel(
name
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:279
Creates a new audio channel.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.createChannel
crossFade()
Section titled “crossFade()”crossFade(
outSoundId
,inSoundId
,channelName
,duration
):Promise
<null
|Tween
>
Defined in: plugins/audio/AudioManagerPlugin.ts:540
Crossfades between two sounds in the specified channel.
Parameters
Section titled “Parameters”outSoundId
Section titled “outSoundId”inSoundId
Section titled “inSoundId”channelName
Section titled “channelName”ChannelName
= 'music'
duration
Section titled “duration”number
= 2
Returns
Section titled “Returns”Promise
<null
| Tween
>
Implementation of
Section titled “Implementation of”destroy()
Section titled “destroy()”destroy():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:247
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”fade()
Section titled “fade()”fade(
soundId
,channelName
,props
,stopOnComplete
):Promise
<null
|Tween
>
Defined in: plugins/audio/AudioManagerPlugin.ts:559
Fades a sound with the specified ID in the specified channel.
Parameters
Section titled “Parameters”soundId
Section titled “soundId”channelName
Section titled “channelName”ChannelName
= 'music'
TweenVars
stopOnComplete
Section titled “stopOnComplete”boolean
= false
Returns
Section titled “Returns”Promise
<null
| Tween
>
Implementation of
Section titled “Implementation of”fadeIn()
Section titled “fadeIn()”fadeIn(
soundId
,channelName
,props
):Promise
<null
|Tween
>
Defined in: plugins/audio/AudioManagerPlugin.ts:488
Fades in a sound with the specified ID in the specified channel.
Parameters
Section titled “Parameters”soundId
Section titled “soundId”channelName
Section titled “channelName”C
= ...
TweenVars
Returns
Section titled “Returns”Promise
<null
| Tween
>
Implementation of
Section titled “Implementation of”fadeOut()
Section titled “fadeOut()”fadeOut(
soundId
,channelName
,props
):Promise
<null
|Tween
>
Defined in: plugins/audio/AudioManagerPlugin.ts:514
Fades out a sound with the specified ID in the specified channel.
Parameters
Section titled “Parameters”soundId
Section titled “soundId”channelName
Section titled “channelName”C
= ...
Partial
<gsap.TweenVars
> = ...
Returns
Section titled “Returns”Promise
<null
| Tween
>
Implementation of
Section titled “Implementation of”getAudioInstance()
Section titled “getAudioInstance()”getAudioInstance(
soundId
,channelName
):undefined
|IAudioInstance
<ChannelName
>
Defined in: plugins/audio/AudioManagerPlugin.ts:609
Parameters
Section titled “Parameters”soundId
Section titled “soundId”channelName
Section titled “channelName”C
= ...
Returns
Section titled “Returns”undefined
| IAudioInstance
<ChannelName
>
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.getAudioInstance
getChannel()
Section titled “getChannel()”getChannel(
name
):undefined
|IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:304
Gets the audio channel with the specified name.
Parameters
Section titled “Parameters”C
Returns
Section titled “Returns”undefined
| IAudioChannel
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.getChannel
initialize()
Section titled “initialize()”initialize(
_options
,app
):Promise
<void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:266
Initializes the AudioManager.
Parameters
Section titled “Parameters”_options
Section titled “_options”any
Returns
Section titled “Returns”Promise
<void
>
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.initialize
Overrides
Section titled “Overrides”isPlaying()
Section titled “isPlaying()”isPlaying(
soundId
,channelName
):boolean
Defined in: plugins/audio/AudioManagerPlugin.ts:421
Parameters
Section titled “Parameters”soundId
Section titled “soundId”string
channelName
Section titled “channelName”C
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”load()
Section titled “load()”load(
soundId
,channelName
,options?
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:619
Parameters
Section titled “Parameters”soundId
Section titled “soundId”AudioAsset
| AudioAsset
[]
channelName
Section titled “channelName”C
= ...
options?
Section titled “options?”PlayOptions
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”mute()
Section titled “mute()”mute():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:311
Mutes the audio.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”pause()
Section titled “pause()”pause():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:327
Pauses the audio.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”play()
Section titled “play()”play(
soundId
,channelName
,options?
):Promise
<IAudioInstance
<ChannelName
>>
Defined in: plugins/audio/AudioManagerPlugin.ts:436
Plays a sound with the specified ID in the specified channel.
Parameters
Section titled “Parameters”soundId
Section titled “soundId”channelName
Section titled “channelName”C
= ...
options?
Section titled “options?”PlayOptions
Returns
Section titled “Returns”Promise
<IAudioInstance
<ChannelName
>>
Implementation of
Section titled “Implementation of”postInitialize()
Section titled “postInitialize()”postInitialize(
_app
):void
|Promise
<void
>
Defined in: plugins/Plugin.ts:67
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
| Promise
<void
>
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.postInitialize
Inherited from
Section titled “Inherited from”restore()
Section titled “restore()”restore():
Promise
<void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:585
Restores the audio state after it has been suspended.
Returns
Section titled “Returns”Promise
<void
>
Implementation of
Section titled “Implementation of”resume()
Section titled “resume()”resume():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:335
Resumes the audio.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setChannelVolume()
Section titled “setChannelVolume()”setChannelVolume(
channelName
,volume
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:292
Sets the volume of the specified channel.
Parameters
Section titled “Parameters”channelName
Section titled “channelName”C
| C
[]
volume
Section titled “volume”number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IAudioManagerPlugin
.setChannelVolume
stop()
Section titled “stop()”stop(
soundId
,channelName
):undefined
|IAudioInstance
<ChannelName
>
Defined in: plugins/audio/AudioManagerPlugin.ts:472
Stops a sound with the specified ID in the specified channel.
Parameters
Section titled “Parameters”soundId
Section titled “soundId”channelName
Section titled “channelName”C
= ...
Returns
Section titled “Returns”undefined
| IAudioInstance
<ChannelName
>
Implementation of
Section titled “Implementation of”stopAll()
Section titled “stopAll()”stopAll(
fade
,duration
,props
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:642
Parameters
Section titled “Parameters”boolean
= false
duration
Section titled “duration”number
= 1
TweenVars
= {}
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”suspend()
Section titled “suspend()”suspend():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:603
Suspends the audio by setting the master volume to 0 and pausing all sounds.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”unmute()
Section titled “unmute()”unmute():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:319
Unmutes the audio.
Returns
Section titled “Returns”void