API Docs for:
Show:

gs.AudioBuffer Class

An audio buffer stream is used to stream an audio track from file. The supported audio formats are MP3, M4A, AAC, OGG and WAV but it depends on the platforms. It is recommended to have at least two versions for each audio file like one file in M4A and the other file in OGG format because some platforms can only play OGG files by default while others can only play MP3/M4A.

Constructor

gs.AudioBuffer

(
  • filePath
  • [reserved=null]
  • [languageCode=null]
)

Parameters:

  • filePath String
    • The path to the audio resource.
  • [reserved=null] Object optional
    • Should be null
  • [languageCode=null] String optional
    • The language code to load the audio-file depending on language.

Methods

decode

()

Decodes the audio data if necessary. Needs to be called once before the audio buffer can be played.

decode

()

Decodes the audio data if necessary. Needs to be called once before the audio buffer can be played.

dispose

()

Disposes the audio buffer and frees the resources/memory. Should be called if the audio buffer is no longer needed.

dispose

()

Disposes the audio buffer and frees the resources/memory. Should be called if the audio buffer is no longer needed.

play

(
  • [fadeInTime=0]
  • [playTime=null]
  • [fadeOutTime=0]
)

Plays the audio buffer.

Parameters:

  • [fadeInTime=0] Number optional
    • The fade-in time in frames.
  • [playTime=null] Number optional
    • The play-time in frames.
  • [fadeOutTime=0] Number optional
    • The fade-out time in frames if play-time is over.

play

(
  • [fadeInTime=0]
  • [playTime=null]
  • [fadeOutTime=0]
)

Plays the audio buffer.

Parameters:

  • [fadeInTime=0] Number optional
    • The fade-in time in frames.
  • [playTime=null] Number optional
    • The play-time in frames.
  • [fadeOutTime=0] Number optional
    • The fade-out time in frames if play-time is over.

resume

(
  • [fadeInTime=0]
)

Resumes the audio buffer if paused.

Parameters:

  • [fadeInTime=0] Number optional
    • The fade-in time in frames.

resume

(
  • [fadeOutTime=0]
)

Stops the audio buffer.

Parameters:

  • [fadeOutTime=0] Number optional
    • The fade-out time in frames.

resume

(
  • [fadeInTime=0]
)

Resumes the audio buffer if paused.

Parameters:

  • [fadeInTime=0] Number optional
    • The fade-in time in frames.

resume

(
  • [fadeOutTime=0]
)

Stops the audio buffer.

Parameters:

  • [fadeOutTime=0] Number optional
    • The fade-out time in frames.

update

()

Updates the audio-buffer. Needs to be called once per frame.

update

()

Updates the audio-buffer. Needs to be called once per frame.

Properties

context

Object

Reference to the audio-context.

context

Object

Reference to the audio-context.

currentTime

Number

The current time as double in seconds.

currentTime

Number

The current play time.

customData

Object

An object which allows to store custom data.

Default: {}

customData

Object

An object which allows to store custom data.

Default: {}

decoded

Boolean

Indicates if the audio-buffer is decoded.

decoded

Boolean

Indicates if the audio-buffer is decoded.

duration

Number

The duration as double in seconds.

fadeInTime

Number

Current fade-in time.

Default: 0

fadeInTime

Number

Current fade-in time.

Default: 0

fadeOutTime

Number

Current fade-out time.

Default: 0

fadeOutTime

Number

Current fade-out time.

Default: 0

isPlaying

Boolean

Indicates if the audio buffer is currently playing.

isPlaying

Boolean

Indicates if the audio buffer is currently playing.

loaded

Boolean

Indicates if the audio-buffer is loaded.

loaded

Boolean

Indicates if the audio-buffer is loaded.

loop

Boolean

Indicates if the audio-buffer repeats after finished.

loop

Boolean

Indicates if the audio-buffer repeats after finished.

playbackRate

Number

The play-back rate in percent.

playbackRate

Number

The play-back rate in percent.

playTime

Number

Current play-time limit in frames.

Default: 0

playTime

Number

Current play-time limit in frames.

Default: 0

volume

Number

The volume. Goes from 0 to 100.

volume

Number

The volume. Goes from 0 to 100.