Constructor

@:value({ loops : 0, length : null, offset : 0, buffer : null })new(?buffer:AudioBuffer, offset:Float = 0, ?length:Float, loops:Int = 0)

Creates a new AudioSource instance.

Parameters:

buffer

The AudioBuffer to associate with this AudioSource.

offset

The starting offset within the audio buffer, in samples.

length

The length of the audio to play, in milliseconds. If null, the full buffer is used.

loops

The number of times to loop the audio. 0 means no looping.

Variables

buffer:AudioBuffer

The AudioBuffer associated with this AudioSource.

currentTime:Float

The current playback position of the audio, in milliseconds.

gain:Float

The gain (volume) of the audio. A value of 1.0 represents the default volume.

read onlylatency:Float

The estimated output latency, in miliseconds, for this AudioSource. If not possible to retrieve will return 0.

NOTE: This will return 0 if the source is not playing!

length:Float

The length of the audio, in milliseconds.

loops:Int

The number of times the audio will loop. A value of 0 means the audio will not loop.

offset:Float

The offset within the audio buffer to start playback, in samples.

@:value(new Event<Void>())onComplete:_Event_Void_Void<() ‑> Void> = new Event<Void>()

An event that is dispatched when the audio playback is complete.

pitch:Float

The pitch of the audio. A value of 1.0 represents the default pitch.

read onlyplaying:Bool

Whether or not this 'AudioSource' is playing.

position:Vector4

The 3D position of the audio source, represented as a Vector4.

Methods

dispose():Void

Releases any resources used by this AudioSource.

pause():Void

Pauses audio playback.

play():Void

Starts or resumes audio playback.

stop():Void

Stops audio playback and resets the playback position to the beginning.