Class LocalAudioTrack

java.lang.Object
com.twilio.video.AudioTrack
com.twilio.video.LocalAudioTrack
All Implemented Interfaces:
Track

public class LocalAudioTrack extends AudioTrack
Represents a local audio source.
  • Method Details

    • create

      @Nullable public static LocalAudioTrack create(@NonNull android.content.Context context, boolean enabled)
      Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
      Parameters:
      context - application context.
      enabled - initial state of audio track.
      Returns:
      local audio track if successfully added or null if audio track could not be created.
    • create

      @Nullable public static LocalAudioTrack create(@NonNull android.content.Context context, boolean enabled, @Nullable AudioOptions audioOptions)
      Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
      Parameters:
      context - application context.
      enabled - initial state of audio track.
      audioOptions - audio options to be applied to the track.
      Returns:
      local audio track if successfully added or null if audio track could not be created.
    • create

      @Nullable public static LocalAudioTrack create(@NonNull android.content.Context context, boolean enabled, @Nullable String name)
      Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
      Parameters:
      context - application context.
      enabled - initial state of audio track.
      name - audio track name.
      Returns:
      local audio track if successfully added or null if audio track could not be created.
    • create

      @Nullable public static LocalAudioTrack create(@NonNull android.content.Context context, boolean enabled, @Nullable AudioOptions audioOptions, @Nullable String name)
      Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
      Parameters:
      context - application context.
      enabled - initial state of audio track.
      audioOptions - audio options to be applied to track.
      name - audio track name.
      Returns:
      local audio track if successfully added or null if audio track could not be created.
    • isEnabled

      public boolean isEnabled()
      Check if the local audio track is enabled.

      When the value is false, the local audio track is muted. When the value is true the local audio track is live.

      Specified by:
      isEnabled in interface Track
      Overrides:
      isEnabled in class AudioTrack
      Returns:
      true if the local audio is enabled.
    • getName

      @NonNull public String getName()
      Returns the local audio track name. A pseudo random string is returned if no track name was specified.
      Specified by:
      getName in interface Track
      Overrides:
      getName in class AudioTrack
    • enable

      public void enable(boolean enable)
      Sets the state of the local audio track. The results of this operation are signaled to other Participants in the same Room. When an audio track is disabled, the audio is muted.
      Parameters:
      enable - the desired state of the local audio track.
    • release

      public void release()
      Releases native memory owned by audio track.
    • addSink

      public void addSink(@NonNull AudioSink audioSink)
      Adds a sink to the Track. Sinks consume raw audio samples for further processing or storage.
      Overrides:
      addSink in class AudioTrack
    • removeSink

      public void removeSink(@NonNull AudioSink audioSink)
      Removes a sink from the Track.
      Overrides:
      removeSink in class AudioTrack
      Parameters:
      audioSink - An object that implements the `AudioSink` interface.