phaser - v4.0.0-rc.4
    Preparing search index...

    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.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    config: SoundConfig

    A config object used to store default sound settings' values. Default values will be set by properties' setters.

    currentConfig: SoundConfig

    Reference to the currently used config. It could be default config or marker config.

    currentMarker: SoundMarker

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

    detune: number

    The detune value of this Sound, given in cents. The range of the value is -1200 to 1200, but we recommend setting it to 50.

    duration: number

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

    isPaused: boolean

    Flag indicating if sound is currently paused.

    isPlaying: boolean

    Flag indicating if sound is currently playing.

    key: string

    Asset key for the sound.

    loop: boolean

    Flag indicating whether or not the sound or current sound marker will loop.

    Local reference to the sound manager.

    markers: { [key: string]: SoundMarker }

    Object containing markers definitions.

    mute: boolean

    Boolean indicating whether the sound is muted or not. Gets or sets the muted state of this sound.

    pan: number

    Gets or sets the pan of this sound, a value between -1 (full left pan) and 1 (full right pan).

    Always returns zero on iOS / Safari as it doesn't support the stereo panner node.

    pendingRemove: boolean

    Flag indicating if destroy method was called on this sound.

    rate: number

    Rate at which this Sound will be played. Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed and 2.0 doubles the audios playback speed.

    seek: number

    Property representing the position of playback for this sound, in seconds. Setting it to a specific value moves current playback to that position. The value given is clamped to the range 0 to current marker duration. Setting seek of a stopped sound has no effect.

    totalDuration: number

    The total duration of the sound in seconds.

    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.

    volume: number

    Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume).

    Methods

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

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

      Returns void

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

      Returns void

    • Calls each of the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • ...args: any[]

        Additional arguments that will be passed to the event handler.

      Returns boolean

    • Return the number of listeners listening to a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns number

    • Return the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns Function[]

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

    • Add a one-time listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

    • Parameters

      • OptionalmarkerName: string | SoundConfig

        If you want to play a marker then provide the marker name here. Alternatively, this parameter can be a SoundConfig object. Default ''.

      • Optionalconfig: SoundConfig

        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.

      Returns boolean

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

    • Parameters

      • markerName: string

        The name of the marker to remove.

      Returns null

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

      Returns void

    • Sets the detune value of this Sound, given in cents. The range of the value is -1200 to 1200, but we recommend setting it to 50.

      Parameters

      • value: number

        The range of the value is -1200 to 1200, but we recommend setting it to 50.

      Returns this

    • Sets the loop state of this Sound.

      Parameters

      • value: boolean

        true to loop this sound, false to not loop it.

      Returns this

    • Sets the muted state of this Sound.

      Parameters

      • value: boolean

        true to mute this sound, false to unmute it.

      Returns this

    • Sets the pan of this sound, a value between -1 (full left pan) and 1 (full right pan).

      Note: iOS / Safari doesn't support the stereo panner node.

      Parameters

      • value: number

        The pan of the sound. A value between -1 (full left pan) and 1 (full right pan).

      Returns this

    • Sets the playback rate of this Sound.

      For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed and 2.0 doubles the audios playback speed.

      Parameters

      • value: number

        The playback rate at of this Sound.

      Returns this

    • Seeks to a specific point in this sound.

      Parameters

      • value: number

        The point in the sound to seek to.

      Returns this

    • Sets the volume of this Sound.

      Parameters

      • value: number

        The volume of the sound.

      Returns this

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

      Parameters

      • time: number

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

      • delta: number

        The delta time elapsed since the last frame.

      Returns void