AudioPlayer object

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

AudioPlayer object


This object represents a target capable of playing audio and offers methods to do so.


You can retrieve instances of AudioPlayer by using "Audio.defaultPlayer" attribute or "room.audioPlayer" attributte.

Characteristics

Methods

Método

Descrição

audioPlayer:asyncAddTrack(audioStream[, params])

Creates an AudioTrack object responsible for playing the audio signal from an AudioStream object.


Arguments:

  • audioStream - an AudioStream object representing the source of the audio signal to be played. It can be obtained by calling the Audio.asyncLoadAudioStream method.
  • (Optional) params - A Lua table with the AudioTrack parameters and may contain the following attributes:
    • autoRemoveOnEOF - A boolean; when true, Firecast will automatically remove the track once the provided audioStream reaches its EOF. Default: false;


Return:


Remarks

  • While an AudioStream object represents the source of an audio signal, an AudioTrack handles the actual playback of the audio signal.
  • An AudioTrack resides within the AudioPlayer, and while active, it continually retrieves audio signals from the provided AudioStream, playing them in real-time.
  • Since the AudioTrack retrieves and plays audio in real-time, any changes made to the provided AudioStream object will also be perceived in real-time during playback. This means you can adjust the volume, pause, and seek audio position using the appropriate AudioStream object properties and methods while the AudioTrack is active.


audioPlayer:play(source[, volume])


Plays an audio file.


Arguments:

  • source - The source of the audio to be played. You can provide:
    • A string containing the external URL of the audio. Example: "https://www.domain.com/my/audioFile.mp3"
    • A string containing the file address in the plugin VHD . Example: "/audios/kick.wav"
    • A Stream object with the audio file content.
  • (Optional) volume - A number representing the volume at which the audio should be played. This number functions as a multiplication factor, where 0.0 means total silence, and 2.0 means double the original audio volume. The default value is 1.0.


Return:


Remarks:

  • The returned promise will be resolved as soon as the audio starts to play.
  • This function will play the audio from start to end only once.
  • You can use the AudioTrack object returned by this function to stop the playback if you wish.
  • The AudioTrack created by this function will be automatically removed from the player once the audio reaches the end.
  • This function maintains a strong reference to the created AudioTrack object while the audio is playing, preventing Lua from garbage collecting it during playback.


Created with the Personal Edition of HelpNDoc: Elevate Your CHM Help Files with HelpNDoc's Advanced Customization Options