Class: NoAudioSound

Phaser.Sound. NoAudioSound

No audio implementation of the sound. It is used if audio has been
disabled in the game config or the device doesn't support any audio.

It represents a graceful degradation of sound logic that provides
minimal functionality and prevents Phaser projects that use audio from
breaking on devices that don't support any audio playback technologies.


new NoAudioSound(manager, key [, config])

Parameters:
Name Type Argument Default Description
manager Phaser.Sound.NoAudioSoundManager

Reference to the current sound manager instance.

key string

Asset key for the sound.

config SoundConfig <optional>
{}

An optional config object containing default sound settings.

Since: 3.0.0
Source: src/sound/noaudio/NoAudioSound.js (Line 13)

Extends

Members


<readonly> currentMarker :SoundMarker

Currently playing marker.
'null' if whole sound is playing.

Type:
Since: 3.0.0
Inherited From:
Default Value:
  • null
Source: src/sound/BaseSound.js (Line 158)

<readonly> duration :number

A value representing the duration, in seconds.
It could be total sound duration or a marker duration.

Type:
  • number
Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 92)

<readonly> isPaused :boolean

Flag indicating if sound is currently paused.

Type:
  • boolean
Since: 3.0.0
Inherited From:
Default Value:
  • false
Source: src/sound/BaseSound.js (Line 68)

<readonly> isPlaying :boolean

Flag indicating if sound is currently playing.

Type:
  • boolean
Since: 3.0.0
Inherited From:
Default Value:
  • false
Source: src/sound/BaseSound.js (Line 57)

<readonly> key :string

Asset key for the sound.

Type:
  • string
Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 47)

<readonly> markers :Object.<string, SoundMarker>

Object containing markers definitions.

Type:
Since: 3.0.0
Inherited From:
Default Value:
  • {}
Source: src/sound/BaseSound.js (Line 147)

<readonly> totalDuration :number

The total duration of the sound in seconds.

Type:
  • number
Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 103)

<readonly> totalRate :number

A property that holds the value of sound's actual playback rate,
after its rate and detune values has been combined with global
rate and detune values.

Type:
  • number
Since: 3.0.0
Inherited From:
Default Value:
  • 1
Source: src/sound/BaseSound.js (Line 79)

Methods


addListener(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 111)
Returns:

this.

Type
Phaser.Events.EventEmitter

addMarker(marker)

Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object.
This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback.

Parameters:
Name Type Description
marker SoundMarker

Marker object.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 182)
Returns:

Whether the marker was added successfully.

Type
boolean

<protected> applyConfig()

Method used internally for applying config values to some of the sound properties.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 406)

<protected> calculateRate()

Method used internally to calculate total playback rate of the sound.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 448)

destroy()

Destroys this sound and all associated events and marks it for removal from the sound manager.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 464)

emit(event [, args])

Calls each of the listeners registered for a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

args * <optional>
<repeatable>

Additional arguments that will be passed to the event handler.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 86)
Returns:

true if the event had listeners, else false.

Type
boolean

eventNames()

Return an array listing the events for which the emitter has registered listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 55)
Returns:
Type
array

listenerCount(event)

Return the number of listeners listening to a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 75)
Returns:

The number of listeners.

Type
number

listeners(event)

Return the listeners registered for a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 64)
Returns:

The registered listeners.

Type
array

off(event, fn, context, once)

Remove the listeners of a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

fn function

Only remove the listeners that match this function.

context *

Only remove the listeners that have this context.

once boolean

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 151)
Returns:

this.

Type
Phaser.Events.EventEmitter

on(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 98)
Returns:

this.

Type
Phaser.Events.EventEmitter

once(event, fn [, context])

Add a one-time listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 124)
Returns:

this.

Type
Phaser.Events.EventEmitter

pause()

Pauses the sound.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 341)
Returns:

Whether the sound was paused successfully.

Type
boolean

play( [markerName] [, config])

Play this sound, or a marked section of it.
It always plays the sound from the start. If you want to start playback from a specific time
you can set 'seek' setting of the config object, provided to this call, to that value.

Parameters:
Name Type Argument Default Description
markerName string <optional>
''

If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound.

config SoundConfig <optional>

Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 282)
Returns:

Whether the sound started playing successfully.

Type
boolean

removeAllListeners( [event])

Remove all listeners, or those of the specified event.

Parameters:
Name Type Argument Description
event string | symbol <optional>

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 165)
Returns:

this.

Type
Phaser.Events.EventEmitter

removeListener(event, fn, context, once)

Remove the listeners of a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

fn function

Only remove the listeners that match this function.

context *

Only remove the listeners that have this context.

once boolean

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 137)
Returns:

this.

Type
Phaser.Events.EventEmitter

removeMarker(markerName)

Removes a marker from the sound.

Parameters:
Name Type Description
markerName string

The name of the marker to remove.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 258)
Returns:

Removed marker object or 'null' if there was no marker with provided name.

Type
SoundMarker

<protected> resetConfig()

Method used internally for resetting values of some of the config properties.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 422)

resume()

Resumes the sound.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 362)
Returns:

Whether the sound was resumed successfully.

Type
boolean

shutdown()

Removes all listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 31)

stop()

Stop playing this sound.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 383)
Returns:

Whether the sound was stopped successfully.

Type
boolean

<protected> update(time, delta)

Update method called automatically by sound manager on every game step.

Parameters:
Name Type Description
time number

The current timestamp as generated by the Request Animation Frame or SetTimeout.

delta number

The delta time elapsed since the last frame.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 435)

updateMarker(marker)

Updates previously added marker.

Parameters:
Name Type Description
marker SoundMarker

Marker object with updated values.

Since: 3.0.0
Inherited From:
Source: src/sound/BaseSound.js (Line 228)
Returns:

Whether the marker was updated successfully.

Type
boolean