Package com.twilio.video
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.
-
-
Field Summary
-
Fields inherited from class com.twilio.video.AudioTrack
audioSinks
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSink(AudioSink audioSink)
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, java.lang.String name)
Creates an audio track.static LocalAudioTrack
create(android.content.Context context, boolean enabled, java.lang.String name)
Creates an audio track.void
enable(boolean enable)
Sets the state of the local audio track.java.lang.String
getName()
Returns the local audio track name.boolean
isEnabled()
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 Detail
-
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 java.lang.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 java.lang.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
@NonNull public java.lang.String 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
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 classAudioTrack
-
removeSink
public void removeSink(@NonNull AudioSink audioSink)
Removes a sink from the Track.- Overrides:
removeSink
in classAudioTrack
- Parameters:
audioSink
- An object that implements the `AudioSink` interface.
-
-