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

    Class containing all the shared state and behavior of a sound object, independent of the implementation.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    currentMarker: SoundMarker

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

    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.

    Local reference to the sound manager.

    markers: { [key: string]: SoundMarker }

    Object containing markers definitions.

    pendingRemove: boolean

    Flag indicating if destroy method was called on this sound.

    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.

    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

    • 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

      Returns boolean

    • 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

    • Pauses the sound. This only works if the sound is currently playing.

      You can inspect the isPlaying and isPaused properties to check the state.

      Returns boolean

    • 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

      • 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

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

      Returns void

    • Resumes the sound. This only works if the sound is paused and not already playing.

      You can inspect the isPlaying and isPaused properties to check the state.

      Returns boolean

    • 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