IAudioManager
All audio manager implementations need to implement this interface to function with the framework.
Properties
autoMuteOnVisibilityChange
autoMuteOnVisibilityChange:
boolean
Source
debug
debug:
boolean
Enabling this will print all debug logs.
Source
masterVolume
masterVolume:
number
The master value that affects all audio.
Source
Methods
createAudioTrack()
createAudioTrack(
trackId
,category
):IAudioTrack
Creates an IAudioTrack.
Parameters
• trackId: string
The id of the track.
• category: string
The category that the track belongs to.
Returns
The created IAudioTrack.
Source
src/audio/IAudioManager.ts:100
fadeTo()
fadeTo(
trackId
,category
,volume
,milliseconds
):void
Fades a track from it’s current volume over time.
Parameters
• trackId: string
The id of the track.
• category: string
The category that the track belongs to.
• volume: number
The volume to fade to.
• milliseconds: number
The time in milliseconds it should take to fade.
Returns
void
Source
getAudioTrack()
getAudioTrack(
trackId
,category
):undefined
|IAudioTrack
Gets a track.
Parameters
• trackId: string
The id of the track.
• category: string
The category that the track belongs to.
Returns
undefined
| IAudioTrack
The IAudioTrack created or undefined if not able to create track. This could happen if the source file could not be found.
Source
src/audio/IAudioManager.ts:109
getCategoryVolume()
getCategoryVolume(
category
):number
Gets the volume of a specific category.
Parameters
• category: string
The category to check.
Returns
number
The volume of the category.
Source
getDuration()
getDuration(
trackId
,category
):undefined
|number
Gets the length of an IAudioTrack.
Parameters
• trackId: string
The id of the track to check.
• category: string
The category that the track belongs to.
Returns
undefined
| number
The length of the track or undefined
if the track doesn’t exist.
Source
init()
init():
void
Sets up any listeners that need the entire Application construction to be complete.
Returns
void
Source
load()
load(
trackIds
,category
,onLoadCallback
?):void
Loads one or more tracks.
Parameters
• trackIds: string
| string
[]
The ids of the tracks to load.
• category: string
The category that the track belongs to.
• onLoadCallback?
The callback to be called when loading is finished.
Returns
void
Source
pause()
pause(
trackId
,category
):undefined
|IAudioTrack
Pauses a track.
Parameters
• trackId: string
The id of the track.
• category: string
The category that the track belongs to.
Returns
undefined
| IAudioTrack
Source
play()
play(
trackId
,volume
?,loop
?,category
?,pitch
?):undefined
|IAudioTrack
Plays a track. If the track does not exist, this function will create it.
Parameters
• trackId: string
The id of the track to play.
• volume?: number
The volume to play the track at. If this function creates the track, this will be the base volume.
• loop?: boolean
Should the track loop or not.
• category?: string
The category that the track belongs to.
• pitch?: number
the pitch of the track
Returns
undefined
| IAudioTrack
The track playing.
Source
setCategoryVolume()
setCategoryVolume(
category
,volume
):void
Sets the volume of a specific category.
Parameters
• category: string
The category to set.
• volume: number
The volume to set.
Returns
void
Source
stop()
stop(
trackId
,category
):undefined
|IAudioTrack
Stops a track.
Parameters
• trackId: string
The id of the track.
• category: string
The category that the track belongs to.
Returns
undefined
| IAudioTrack
Source
unload()
unload(
trackId
,category
,removeTrack
):void
Unloads a track’s source from memory.
Parameters
• trackId: string
The id of the track.
• category: string
The category that the track belongs to.
• removeTrack: boolean
Whether the IAudioTrack should be removed and destroyed too.
Returns
void