Kiwi.Sound.AudioManager Class
Manages the initialisation of assets necessary when dealing with audio in the game, either through Audio Tags or the Web Audio API. Also provides global sound controls that will be applyed to all Audio objects at the same time, within the Game this manager is a part of.
Constructor
Kiwi.Sound.AudioManager
-
game
Parameters:
-
game
Kiwi.GameThe game that this audio manager belongs to.
Returns:
Item Index
Methods
Methods
_unlocked
()
private
Is executed when a mouse event is fired on the device. This is used to enabled playback of sounds on the current device if they were awaiting for a user event.
add
-
key
-
[volume=1]
-
[loop=false]
Used to create a new sound on the audio manager. Returns the newly created sound.
Parameters:
-
key
StringThe key for the audio file that is to be loaded from the AudioLibrary.
-
[volume=1]
Number optionalThe volume for the piece of audio.
-
[loop=false]
Boolean optionalIf the audio should keep repeat when it gets to the end.
Returns:
boot
()
public
The boot method is executed when all of the DOM elements needed for the game are loaded and the game is ready to 'start' up.
isRegistered
-
sound
Indicates whether or not an Audio Object is registered with this Audio Manager or not. For Kiwi Internal use only.
Parameters:
-
sound
AudioThe Audio object you are checking for.
Returns:
If the piece of audio is registered or not.
objType
()
String
public
The type of object that this is.
Returns:
"AudioManager"
pauseAll
()
public
Pauses all of the sounds listed in the AudioManager.
playAll
()
public
Plays all of the sounds listed in the AudioManager.
registerSound
-
sound
Registers an Audio Object with this audio manager. Also assign's the audio piece a unique ID to identify it by. Internal Kiwi use only.
Parameters:
-
sound
AudioThe audio piece you are wanting to register.
Returns:
Indication of if the sound was successfully added or not.
remove
-
sound
-
[destory=true]
Removes the passed sound from the AudioManager. If you remove a Audio Object from the AudioManager, then that Audio Object will not have a update loop.
Parameters:
-
sound
Kiwi.Sound.AudioThe Audio object that you want to remove.
-
[destory=true]
Object optionalIf the Audio Object should be removed or not.
resumeAll
()
public
Resumes all of the sounds listed in the AudioManager.
stopAll
()
public
Stops all of the sounds that are listed in the AudioManager from playing.
update
()
public
The update loop that is executed every frame.
Properties
_locked
Boolean
private
Indicates if the sounds is currently 'locked' or not. If it is 'locked' then no audio can play until a user touch's the device.
_muted
Boolean
private
A boolean that controls whether the whole games audio should be muted or not.
Default: false
_muteVolume
Number
private
The volume of the audio before it was muted. This is used so that when the audio is unmuted the volume will resume at this point.
_sounds
Array
private
An array containing all of the sounds on the game.
_unlockedSource
Any
private
Sound buffer
_volume
Number
private
The global volume of all of the games audio.
Default: 1
channels
Number
public
The number of channels that are supported. Not in much use at this point in time.
context
Any
public
Web Audio API ONLY - The audio context that is used for decoding audio, e.t.c.
locked
Boolean
public
Returns a boolean indicating whether the device has been touched or not. READ ONLY.
masterGain
Any
public
Web Audio API ONLY - The master gain node through which all sounds play.
mute
Boolean
public
Used to mute the audio on the device, or to check to see if the device is muted. This will not stop audio from being played, will just mean that the audio is silent.
Default: false
noAudio
Boolean
public
If the current game has audio support or not. Useful because audio support is spotty in mobile browsers.
usingAudioTag
Boolean
public
If the game is using audio tags for the sound. This is the fallback if the web audio api is not supported.
usingWebAudio
Boolean
public
If the game is currently using the Web Audio API for the sound.
volume
Number
public
Global setting and getting of the volume. A number between 0 (silence) and 1 (full volume).
Default: 1