-
- All Implemented Interfaces:
-
io.elevenlabs.audio.AudioManager
public final class LiveKitAudioManager implements AudioManager
LiveKit-based audio implementation
This class manages local audio tracks for microphone input, handles remote audio tracks for agent speech, configures audio quality and encoding settings, and implements audio focus management for Android.
-
-
Field Summary
Fields Modifier and Type Field Description private final StateFlow<Boolean>recordingStateprivate final StateFlow<Boolean>playbackStateprivate final StateFlow<Boolean>muteStateprivate final StateFlow<Float>volumeState
-
Constructor Summary
Constructors Constructor Description LiveKitAudioManager(Context context, Room room, SoftwareMuteProcessor softwareMuteProcessor)
-
Method Summary
Modifier and Type Method Description final StateFlow<Boolean>getRecordingState()Get current recording state as StateFlow for reactive UI updates final StateFlow<Boolean>getPlaybackState()Get current playback state as StateFlow for reactive UI updates final StateFlow<Boolean>getMuteState()Get current mute state as StateFlow for reactive UI updates final StateFlow<Float>getVolumeState()Get current volume as StateFlow for reactive UI updates UnitstartRecording()Start recording from the microphone UnitstopRecording()Stop recording from the microphone UnitstartPlayback()Start audio playback for incoming audio UnitstopPlayback()Stop audio playback UnitsetMicMuted(Boolean muted)Set the microphone mute state UnitsetMicrophoneMuted(Boolean muted)Mute the microphone at the OS/track level BooleanisMuted()Check if the microphone is currently muted UnitsetVolume(Float volume)Set the playback volume FloatgetVolume()Get the current playback volume BooleanhasAudioPermission()Check if audio recording permission is granted BooleanisRecording()Check if audio recording is currently active BooleanisPlaying()Check if audio playback is currently active UnitsetAudioStateListener(AudioStateListener listener)Set listener for audio state changes Unitcleanup()Clean up audio resources Should be called when audio management is no longer needed final UnitaddRemoteAudioTrack(RemoteAudioTrack track)Add a remote audio track for playback This should be called when a new remote participant joins final UnitremoveRemoteAudioTrack(RemoteAudioTrack track)Remove a remote audio track This should be called when a remote participant leaves -
-
Constructor Detail
-
LiveKitAudioManager
LiveKitAudioManager(Context context, Room room, SoftwareMuteProcessor softwareMuteProcessor)
-
-
Method Detail
-
getRecordingState
final StateFlow<Boolean> getRecordingState()
Get current recording state as StateFlow for reactive UI updates
-
getPlaybackState
final StateFlow<Boolean> getPlaybackState()
Get current playback state as StateFlow for reactive UI updates
-
getMuteState
final StateFlow<Boolean> getMuteState()
Get current mute state as StateFlow for reactive UI updates
-
getVolumeState
final StateFlow<Float> getVolumeState()
Get current volume as StateFlow for reactive UI updates
-
startRecording
Unit startRecording()
Start recording from the microphone
-
stopRecording
Unit stopRecording()
Stop recording from the microphone
-
startPlayback
Unit startPlayback()
Start audio playback for incoming audio
-
stopPlayback
Unit stopPlayback()
Stop audio playback
-
setMicMuted
Unit setMicMuted(Boolean muted)
Set the microphone mute state
- Parameters:
muted- true to mute microphone, false to unmute
-
setMicrophoneMuted
Unit setMicrophoneMuted(Boolean muted)
Mute the microphone at the OS/track level
- Parameters:
muted- true to mute, false to unmute
-
setVolume
Unit setVolume(Float volume)
Set the playback volume
- Parameters:
volume- Volume level from 0.0 (silent) to 1.
-
hasAudioPermission
Boolean hasAudioPermission()
Check if audio recording permission is granted
-
isRecording
Boolean isRecording()
Check if audio recording is currently active
-
setAudioStateListener
Unit setAudioStateListener(AudioStateListener listener)
Set listener for audio state changes
- Parameters:
listener- Callback for audio state events
-
cleanup
Unit cleanup()
Clean up audio resources Should be called when audio management is no longer needed
-
addRemoteAudioTrack
final Unit addRemoteAudioTrack(RemoteAudioTrack track)
Add a remote audio track for playback This should be called when a new remote participant joins
-
removeRemoteAudioTrack
final Unit removeRemoteAudioTrack(RemoteAudioTrack track)
Remove a remote audio track This should be called when a remote participant leaves
-
-
-
-