AudioManagerPlugin
Defined in: plugins/audio/AudioManagerPlugin.ts:91
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:135
Creates a new AudioManager instance.
Parameters
id
string
= 'audio'
The ID of the AudioManager. Default is ‘AudioManager’.
Returns
Overrides
Properties
__dill_pixel_method_binding_root
__dill_pixel_method_binding_root:
boolean
Defined in: plugins/Plugin.ts:39
Inherited from
Plugin
.__dill_pixel_method_binding_root
id
id:
string
='Plugin'
Defined in: plugins/Plugin.ts:48
Implementation of
Inherited from
onChannelMuted
onChannelMuted:
Signal
<(detail
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:123
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:116
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:111
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:106
Signal that is emitted when the system is muted or unmuted.
Implementation of
onSoundEnded
onSoundEnded:
Signal
<(detail
) =>void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:102
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:97
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():
A
Defined in: plugins/Plugin.ts:53
Returns
A
Implementation of
Inherited from
channels
Get Signature
get channels():
Map
<string
,IAudioChannel
>
Defined in: plugins/audio/AudioManagerPlugin.ts:187
Gets the map of audio channels.
Returns
Map
<string
, IAudioChannel
>
The map of audio channels.
Implementation of
masterVolume
Get Signature
get masterVolume():
number
Defined in: plugins/audio/AudioManagerPlugin.ts:149
Gets the master volume.
Returns
number
The master volume.
Set Signature
set masterVolume(
value
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:157
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:191
Returns
Implementation of
muted
Get Signature
get muted():
boolean
Defined in: plugins/audio/AudioManagerPlugin.ts:168
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:176
Sets whether the audio is muted.
Parameters
value
boolean
True to mute the audio, false to unmute.
Returns
void
Implementation of
options
Get Signature
get options():
O
Defined in: plugins/Plugin.ts:44
Returns
O
Implementation of
Inherited from
paused
Get Signature
get paused():
boolean
Defined in: plugins/audio/AudioManagerPlugin.ts:300
Returns
boolean
Implementation of
sfx
Get Signature
get sfx():
IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:195
Returns
Implementation of
vo
Get Signature
get vo():
IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:203
Returns
Implementation of
voiceover
Get Signature
get voiceover():
IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:199
Returns
Implementation of
Methods
add()
add(
soundAsset
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:363
Adds a sound asset to the AudioManager.
Parameters
soundAsset
UnresolvedAsset
Returns
void
Implementation of
addAllFromBundle()
addAllFromBundle(
bundleName
,manifest
?):void
Defined in: plugins/audio/AudioManagerPlugin.ts:331
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:308
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:79
Add signal connections to the container.
Parameters
args
…SignalConnection
[]
The signal connections to add.
Returns
void
Implementation of
IAudioManagerPlugin
.addSignalConnection
Inherited from
clearSignalConnections()
clearSignalConnections():
void
Defined in: plugins/Plugin.ts:85
Returns
void
Implementation of
IAudioManagerPlugin
.clearSignalConnections
Inherited from
createChannel()
createChannel(
name
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:239
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:502
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
destroy()
destroy():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:207
Returns
void
Implementation of
Overrides
fade()
fade(
soundId
,channelName
,props
,stopOnComplete
):Promise
<null
|Tween
>
Defined in: plugins/audio/AudioManagerPlugin.ts:521
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
fadeIn()
fadeIn(
soundId
,channelName
,props
):Promise
<null
|Tween
>
Defined in: plugins/audio/AudioManagerPlugin.ts:450
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
fadeOut()
fadeOut(
soundId
,channelName
,props
):Promise
<null
|Tween
>
Defined in: plugins/audio/AudioManagerPlugin.ts:476
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
getAudioInstance()
getAudioInstance(
soundId
,channelName
):undefined
|IAudioInstance
<ChannelName
>
Defined in: plugins/audio/AudioManagerPlugin.ts:571
Parameters
soundId
string
channelName
C
= ...
Returns
undefined
| IAudioInstance
<ChannelName
>
Implementation of
IAudioManagerPlugin
.getAudioInstance
getChannel()
getChannel(
name
):undefined
|IAudioChannel
Defined in: plugins/audio/AudioManagerPlugin.ts:264
Gets the audio channel with the specified name.
Parameters
name
C
Returns
undefined
| IAudioChannel
Implementation of
IAudioManagerPlugin
.getChannel
initialize()
initialize(
_options
,app
):Promise
<void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:226
Initializes the AudioManager.
Parameters
_options
any
app
Returns
Promise
<void
>
Implementation of
IAudioManagerPlugin
.initialize
Overrides
isPlaying()
isPlaying(
soundId
,channelName
):boolean
Defined in: plugins/audio/AudioManagerPlugin.ts:382
Parameters
soundId
string
channelName
C
Returns
boolean
Implementation of
load()
load(
soundId
,channelName
,options
?):void
Defined in: plugins/audio/AudioManagerPlugin.ts:581
Parameters
soundId
string
| string
[]
channelName
C
= ...
options?
PlayOptions
Returns
void
Implementation of
mute()
mute():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:271
Mutes the audio.
Returns
void
Implementation of
pause()
pause():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:287
Pauses the audio.
Returns
void
Implementation of
play()
play(
soundId
,channelName
,options
?):Promise
<IAudioInstance
<ChannelName
>>
Defined in: plugins/audio/AudioManagerPlugin.ts:398
Plays a sound with the specified ID in the specified channel.
Parameters
soundId
string
channelName
C
= ...
options?
PlayOptions
Returns
Promise
<IAudioInstance
<ChannelName
>>
Implementation of
postInitialize()
postInitialize(
_app
):void
|Promise
<void
>
Defined in: plugins/Plugin.ts:68
Parameters
_app
Returns
void
| Promise
<void
>
Implementation of
IAudioManagerPlugin
.postInitialize
Inherited from
restore()
restore():
Promise
<void
>
Defined in: plugins/audio/AudioManagerPlugin.ts:547
Restores the audio state after it has been suspended.
Returns
Promise
<void
>
Implementation of
resume()
resume():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:295
Resumes the audio.
Returns
void
Implementation of
setChannelVolume()
setChannelVolume(
channelName
,volume
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:252
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
<ChannelName
>
Defined in: plugins/audio/AudioManagerPlugin.ts:434
Stops a sound with the specified ID in the specified channel.
Parameters
soundId
string
channelName
C
= ...
Returns
undefined
| IAudioInstance
<ChannelName
>
Implementation of
stopAll()
stopAll(
fade
,duration
,props
):void
Defined in: plugins/audio/AudioManagerPlugin.ts:604
Parameters
fade
boolean
= false
duration
number
= 1
props
TweenVars
= {}
Returns
void
Implementation of
suspend()
suspend():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:565
Suspends the audio by setting the master volume to 0 and pausing all sounds.
Returns
void
Implementation of
unmute()
unmute():
void
Defined in: plugins/audio/AudioManagerPlugin.ts:279
Unmutes the audio.
Returns
void