Constructor

@:value({ loops : 0, length : null, offset : 0, buffer : null })new(?buffer:AudioBuffer, offset:Int = 0, ?length:Int, 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:Int

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.

length:Int

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:Int

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.

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.