Package com.twilio.video
Class LocalAudioTrack
java.lang.Object
com.twilio.video.AudioTrack
com.twilio.video.LocalAudioTrack
- All Implemented Interfaces:
Track
Represents a local audio source.
-
Field Summary
Fields inherited from class com.twilio.video.AudioTrack
audioSinks
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a sink to the Track.static LocalAudioTrack
create
(android.content.Context context, boolean enabled) Creates an audio track.static LocalAudioTrack
create
(android.content.Context context, boolean enabled, AudioOptions audioOptions) Creates an audio track.static LocalAudioTrack
create
(android.content.Context context, boolean enabled, AudioOptions audioOptions, String name) Creates an audio track.static LocalAudioTrack
Creates an audio track.void
enable
(boolean enable) Sets the state of the local audio track.getName()
Returns the local audio track name.boolean
Check if the local audio track is enabled.void
release()
Releases native memory owned by audio track.void
removeSink
(AudioSink audioSink) Removes a sink from the Track.
-
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 interfaceTrack
- Overrides:
isEnabled
in classAudioTrack
- Returns:
- true if the local audio is enabled.
-
getName
Returns the local audio track name. A pseudo random string is returned if no track name was specified.- Specified by:
getName
in interfaceTrack
- Overrides:
getName
in classAudioTrack
-
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
Adds a sink to the Track. Sinks consume raw audio samples for further processing or storage.- Overrides:
addSink
in classAudioTrack
-
removeSink
Removes a sink from the Track.- Overrides:
removeSink
in classAudioTrack
- Parameters:
audioSink
- An object that implements the `AudioSink` interface.
-