Skip to main content

Audio

Description:

  A record of an audio player singleton object.

play

Type: Function.

Description:

  Plays a sound effect and returns a handler for the audio.

Signature:

play: function(
self: Audio,
filename: string,
loop?: boolean --[[false]]
): integer

Parameters:

ParameterTypeDescription
filenamestringThe path to the sound effect file (must be a WAV file).
loopboolean[optional] Whether to loop the sound effect (default is false).

Returns:

Return TypeDescription
integerA handler for the audio that can be used to stop the sound effect.

stop

Type: Function.

Description:

  Stops a sound effect that is currently playing.

Signature:

stop: function(self: Audio, handler: integer)

Parameters:

ParameterTypeDescription
handlerintegerThe handler for the audio that is returned by the play function.

playStream

Type: Function.

Description:

  Plays a streaming audio file.

Signature:

playStream: function(
self: Audio,
filename: string,
loop?: boolean --[[false]],
crossFadeTime?: number --[[0.0]]
)

Parameters:

ParameterTypeDescription
filenamestringThe path to the streaming audio file (can be OGG, WAV, MP3, or FLAC).
loopboolean[optional] Whether to loop the streaming audio (default is false).
crossFadeTimenumber[optional] The time (in seconds) to crossfade between the previous and new streaming audio (default is 0.0).

stopStream

Type: Function.

Description:

  Stops a streaming audio file that is currently playing.

Signature:

stopStream: function(
self: Audio,
fadeTime?: number --[[0.0]]
)

Parameters:

ParameterTypeDescription
fadeTimenumber[optional] The time (in seconds) to fade out the streaming audio (default is 0.0).