Class: SoundManager

Phaser. SoundManager

Phaser Sound Manager.

new SoundManager(game)

Sound Manager constructor. The Sound Manager is responsible for playing back audio via either the Legacy HTML Audio tag or via Web Audio if the browser supports it. Note: On Firefox 25+ on Linux if you have media.gstreamer disabled in about:config then it cannot play back mp3 or m4a files.

Parameters:
Name Type Description
game Phaser.Game

reference to the current game instance.

Source:

Members

channels

Properties:
Name Type Description
channels number

The number of audio channels to use in playback.

Default Value:
  • 32
Source:

connectToMaster

Properties:
Name Type Description
connectToMaster boolean

Used in conjunction with Sound.externalNode this allows you to stop a Sound node being connected to the SoundManager master gain node.

Default Value:
  • true
Source:

context

Properties:
Name Type Description
context AudioContext

The AudioContext being used for playback.

Default Value:
  • null
Source:

game

Properties:
Name Type Description
game Phaser.Game

Local reference to game.

Source:

mute

Properties:
Name Type Description
mute boolean

Gets or sets the muted state of the SoundManager. This effects all sounds in the game.

Source:

noAudio

Properties:
Name Type Description
noAudio boolean

Has audio been disabled via the PhaserGlobal object? Useful if you need to use a 3rd party audio library instead.

Default Value:
  • false
Source:

onSoundDecode

Properties:
Name Type Description
onSoundDecode Phaser.Signal

The event dispatched when a sound decodes (typically only for mp3 files)

Source:

touchLocked

Properties:
Name Type Description
touchLocked boolean

true if the audio system is currently locked awaiting a touch event.

Default Value:
  • false
Source:

<readonly> usingAudioTag

Properties:
Name Type Description
usingAudioTag boolean

true if the sound is being played via the Audio tag.

Source:

<readonly> usingWebAudio

Properties:
Name Type Description
usingWebAudio boolean

true if this sound is being played with Web Audio.

Source:

volume

Properties:
Name Type Description
volume number

Gets or sets the global volume of the SoundManager, a value between 0 and 1.

Source:

Methods

add(key, volume, loop, connect) → {Phaser.Sound}

Adds a new Sound into the SoundManager.

Parameters:
Name Type Argument Default Description
key string

Asset key for the sound.

volume number <optional>
1

Default value for the volume.

loop boolean <optional>
false

Whether or not the sound will loop.

connect boolean <optional>
true

Controls if the created Sound object will connect to the master gainNode of the SoundManager when running under WebAudio.

Source:
Returns:

The new sound instance.

Type
Phaser.Sound

<protected> boot()

Initialises the sound manager.

Source:

decode(key, sound)

Decode a sound by its assets key.

Parameters:
Name Type Argument Description
key string

Assets key of the sound to be decoded.

sound Phaser.Sound <optional>

Its buffer will be set to decoded data.

Source:

pauseAll()

Pauses all the sounds in the game.

Source:

play(key, volume, loop, destroyOnComplete) → {Phaser.Sound}

Adds a new Sound into the SoundManager and starts it playing.

Parameters:
Name Type Argument Default Description
key string

Asset key for the sound.

volume number <optional>
1

Default value for the volume.

loop boolean <optional>
false

Whether or not the sound will loop.

destroyOnComplete boolean <optional>
false

If true the Sound will destroy itself once it has finished playing, or is stopped.

Source:
Returns:

The new sound instance.

Type
Phaser.Sound

resumeAll()

resumes every sound in the game.

Source:

stopAll()

Stops all the sounds in the game.

Source:

unlock()

Enables the audio, usually after the first touch.

Source:

update()

Updates every sound in the game.

Source:
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Tue Feb 18 2014 03:01:26 GMT-0000 (GMT) using the DocStrap template.