AudioStream object

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

AudioStream object

An AudioStream object represents a source of audio signal and can be created by calling the Audio.asyncLoadAudioStream() function. However, it does not play audio on its own. To play it, you must also create an AudioTrack object using the "asyncAddTrack" method of a target AudioPlayer object


During playback of an AudioStream through an AudioTrack object, any alterations made to the AudioStream object are immediately reflected in real-time. This allows you to adjust parameters such as volume, pause, and audio position using the pertinent AudioStream object properties and methods while the AudioTrack is actively playing.


Characteristics

Propertys and attributes

Propriedade

Tipo

Descrição

enabled

Boolean

Indicates whether the AudioStream can output audio signal.


If the AudioStream is being played by an AudioTrack, setting this attribute to false will pause the playback, as no audio signal will be outputted. Setting it back to true will resume the playback.


Default: True

eof

Boolean

(Read-only) Indicates whether the AudioStream has reached its EOF (end of file).


length

Float

(Read-only) If the duration of the audio is known, this attribute contains its duration in seconds; otherwise, it is set to nil.


Remarks:

  • Please be aware that this attribute may be nil instead of a number, so make sure to handle this possibility in your code.


position

Float

If the current audio stream is seekable and its position is defined, this contains the stream position in seconds; otherwise, it is set to nil.


Remarks:

  • When setting a value to this attribute, Firecast will seek the audio stream to the closest keyframe, and its true audio position can be slightly earlier than desired.
  • Please be aware that this attribute may be nil instead of a number, so make sure to handle this possibility in your code.
  • Additionally, when the audio stream is being played by an AudioTrack in real-time, this value will be updated dynamically, allowing you to track the playback progress


volume

Float

A numerical value representing the output volume level of the audio signal from the AudioStream. This value acts as a multiplication factor, with 0.0 indicating complete silence, and 2.0 indicating twice the original audio volume. The default value is 1.0



Methods

Método

Descrição

audioStream:setPosition(newPosition)

Seeks the audio stream to a specified position.


Arguments:

  • newPosition - A number indicating the desired position, in seconds, to which Firecast should seek the audio stream.


Return:

  • A boolean value indicating whether the audio seek was successful.


Remarks:

  • Firecast will seek the audio stream to the nearest keyframe, which may result in the true audio position being slightly earlier than desired.
  • If the audio stream is not seekable, the method will return false.
  • Calling this method is equivalent to setting the "position" property, but with the added benefit of being able to check the success of the seek operation.


audioStream:waitEOF();

Sets up a monitoring that waits for the AudioStream to reach its end of file (EOF).


Arguments:

None


Return:

  • A promise that will be resolved when the AudioStream reaches its end of file (EOF).


Remarks:

  • If the AudioStream is already at the EOF, the returned promise will be resolved immediately.



Events


Nome do evento

Descrição

onEOF


This event is triggered by Firecast when the AudioStream reaches its end of file (EOF).

Created with the Personal Edition of HelpNDoc: Easily create Help documents