AudioTrack object

.html ›› .html ›› .html ››
Parent Previous Next

AudioTrack object

An AudioTrack object serves as a real-time agent that continuously fetches audio signals from an AudioStream and plays them. While AudioStream objects provide audio signals, it's the AudioTrack objects residing within an AudioPlayer that actually play them.


Lifecycle

AudioTracks are created using the AudioPlayer's asyncAddTrack method.


While active, AudioTracks continuously retrieve audio signals from their associated AudioStream, playing them in real-time. As AudioTracks retrieve and play audio in real-time, any changes made to their associated AudioStream objects will also be immediately reflected in the playback. This allows you to adjust the volume, pause, and seek audio position using the relevant AudioStream object properties and methods while the AudioTrack is in operation.


AudioTracks can be stopped by calling their "remove" method. If the Lua Garbage Collector collects an AudioTrack object, it will also be automatically stopped.


Additionally, AudioTracks can be forcibly removed by Firecast. For example, when a user leaves the room, all audio transmission to that room must cease. You can use waitRemoval method, removed attribute, and/or onRemove event to monitor when this occurs.

Characteristics

Propertys and attributes

Propriedade

Tipo

Descrição

audioStream

AudioStream object

(Read-only) The associated AudioStream object providing audio signal to the AudioTrack.


Remarks:

  • As AudioTracks retrieve and play audio in real-time, any changes made to this AudioStream object will also be immediately reflected in the playback. This allows you to adjust the volume, pause, and seek audio position using the relevant AudioStream object properties and methods while the AudioTrack is in operation.

removed

Boolean

(Read-only) Indicates whether the track has been removed from its AudioPlayer object.

Remarks

  • Once a track is removed, it cannot be reactivated. However, its associated AudioStream object can be reused.



Methods

Método

Descrição

audioTrack:remove()

Removes the AudioTrack from its AudioPlayer, halting the playback.


Arguments:

None


Return:

  • A promise that can be used to track the asynchronous process of AudioTrack removal.


Remarks

  • Once a track is removed, it cannot be reactivated. However, its associated AudioStream object can be reused.


audioTrack:waitRemoval()

Sets up a wait that monitors the removal state of the AudioTrack.


Arguments:

None


Return:

  • A promise that will be resolved when the AudioTrack is removed from its AudioPlayer.


Remarks:

  • This function does not remove the AudioTrack; it simply monitors when it happens.
  • If the AudioTrack is already removed, the returned promise will be resolved immediately.
  • Once a track is removed, it cannot be reactivated. However, its associated AudioStream object can be reused.



Events


Nome do evento

Descrição

onRemoved


This event is triggered by Firecast when the AudioTrack is removed from its AudioPlayer.


Remarks:

  • Once a track is removed, it cannot be reactivated. However, its associated AudioStream object can be reused.

Created with the Personal Edition of HelpNDoc: Don't Let Unauthorized Users View Your PDFs: Learn How to Set Passwords