SpeakerManager

class SpeakerManager(val mediaManager: MediaManagerImpl, val microphoneManager: MicrophoneManager, val initialVolume: Int? = null, val audioUsageProvider: () -> Int = { defaultAudioUsage })

Constructors

Link copied to clipboard
constructor(mediaManager: MediaManagerImpl, microphoneManager: MicrophoneManager, initialVolume: Int? = null, audioUsageProvider: () -> Int = { defaultAudioUsage })

Properties

Link copied to clipboard
val audioUsage: StateFlow<Int>
Link copied to clipboard
Link copied to clipboard
val devices: StateFlow<List<StreamAudioDevice>>
Link copied to clipboard
val initialVolume: Int? = null
Link copied to clipboard
val isEnabled: StateFlow<Boolean>

Represents whether the speakerphone is enabled

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val status: StateFlow<DeviceStatus>
Link copied to clipboard
val volume: StateFlow<Int?>

Functions

Link copied to clipboard
fun disable(fromUser: Boolean = true)
Link copied to clipboard
fun pause()
Link copied to clipboard
fun resume()
Link copied to clipboard
fun setAudioUsage(audioUsage: Int): Boolean

Set the audio usage value. This allows toggling between USAGE_MEDIA and USAGE_VOICE_COMMUNICATION. Updates the StateFlow immediately for responsive UI, then attempts to update the ADM. If the ADM update fails, the StateFlow is rolled back to the previous value.

Link copied to clipboard
fun setEnabled(enabled: Boolean, fromUser: Boolean = true)

Enable or disable the speakerphone.

Link copied to clipboard
fun setSpeakerPhone(enable: Boolean, defaultFallback: StreamAudioDevice? = null)

Enables or disables the speakerphone.

Link copied to clipboard
fun setVolume(volumePercentage: Int)

Set the volume as a percentage, 0-100