AudioSessionManager
Manages the platform audio session, controlling how the app interacts with the system audio infrastructure and other audio apps.
On Apple platforms, this wraps AVAudioSession and must be configured before opening audio streams. On Android, call bind(context) then setActive to request audio focus; interruptions are reported via observeInterruptions.
Example usage:
val sessionManager = AudioSessionManager()
// Configure for simultaneous recording and playback
sessionManager.configure(
category = AudioSessionCategory.PLAY_AND_RECORD,
mode = AudioSessionMode.MEASUREMENT,
)
// Activate the session before opening streams
sessionManager.setActive(true)
// Listen for route changes (e.g., headphones plugged in/out)
sessionManager.observeRouteChanges { info ->
println("Audio route changed: ${info.reason}")
}
// Deactivate when audio is no longer needed
sessionManager.setActive(false)See also
Manages the platform audio session, controlling how the app interacts with the system audio infrastructure and other audio apps.
On Apple platforms, this wraps AVAudioSession and must be configured before opening audio streams. On Android, call bind(context) then setActive to request audio focus; interruptions are reported via observeInterruptions.
Example usage:
val sessionManager = AudioSessionManager()
// Configure for simultaneous recording and playback
sessionManager.configure(
category = AudioSessionCategory.PLAY_AND_RECORD,
mode = AudioSessionMode.MEASUREMENT,
)
// Activate the session before opening streams
sessionManager.setActive(true)
// Listen for route changes (e.g., headphones plugged in/out)
sessionManager.observeRouteChanges { info ->
println("Audio route changed: ${info.reason}")
}
// Deactivate when audio is no longer needed
sessionManager.setActive(false)See also
Manages the platform audio session, controlling how the app interacts with the system audio infrastructure and other audio apps.
On Apple platforms, this wraps AVAudioSession and must be configured before opening audio streams. On Android, call bind(context) then setActive to request audio focus; interruptions are reported via observeInterruptions.
Example usage:
val sessionManager = AudioSessionManager()
// Configure for simultaneous recording and playback
sessionManager.configure(
category = AudioSessionCategory.PLAY_AND_RECORD,
mode = AudioSessionMode.MEASUREMENT,
)
// Activate the session before opening streams
sessionManager.setActive(true)
// Listen for route changes (e.g., headphones plugged in/out)
sessionManager.observeRouteChanges { info ->
println("Audio route changed: ${info.reason}")
}
// Deactivate when audio is no longer needed
sessionManager.setActive(false)See also
Manages the platform audio session, controlling how the app interacts with the system audio infrastructure and other audio apps.
On Apple platforms, this wraps AVAudioSession and must be configured before opening audio streams. On Android, call bind(context) then setActive to request audio focus; interruptions are reported via observeInterruptions.
Example usage:
val sessionManager = AudioSessionManager()
// Configure for simultaneous recording and playback
sessionManager.configure(
category = AudioSessionCategory.PLAY_AND_RECORD,
mode = AudioSessionMode.MEASUREMENT,
)
// Activate the session before opening streams
sessionManager.setActive(true)
// Listen for route changes (e.g., headphones plugged in/out)
sessionManager.observeRouteChanges { info ->
println("Audio route changed: ${info.reason}")
}
// Deactivate when audio is no longer needed
sessionManager.setActive(false)See also
Manages the platform audio session, controlling how the app interacts with the system audio infrastructure and other audio apps.
On Apple platforms, this wraps AVAudioSession and must be configured before opening audio streams. On Android, call bind(context) then setActive to request audio focus; interruptions are reported via observeInterruptions.
Example usage:
val sessionManager = AudioSessionManager()
// Configure for simultaneous recording and playback
sessionManager.configure(
category = AudioSessionCategory.PLAY_AND_RECORD,
mode = AudioSessionMode.MEASUREMENT,
)
// Activate the session before opening streams
sessionManager.setActive(true)
// Listen for route changes (e.g., headphones plugged in/out)
sessionManager.observeRouteChanges { info ->
println("Audio route changed: ${info.reason}")
}
// Deactivate when audio is no longer needed
sessionManager.setActive(false)See also
Manages the platform audio session, controlling how the app interacts with the system audio infrastructure and other audio apps.
On Apple platforms, this wraps AVAudioSession and must be configured before opening audio streams. On Android, call bind(context) then setActive to request audio focus; interruptions are reported via observeInterruptions.
Example usage:
val sessionManager = AudioSessionManager()
// Configure for simultaneous recording and playback
sessionManager.configure(
category = AudioSessionCategory.PLAY_AND_RECORD,
mode = AudioSessionMode.MEASUREMENT,
)
// Activate the session before opening streams
sessionManager.setActive(true)
// Listen for route changes (e.g., headphones plugged in/out)
sessionManager.observeRouteChanges { info ->
println("Audio route changed: ${info.reason}")
}
// Deactivate when audio is no longer needed
sessionManager.setActive(false)See also
Constructors
Functions
Pause and resume this stream automatically on interruptions. Does not start playback by itself. Does not close the stream.
Pause and resume this stream automatically on interruptions. Does not start playback by itself. Does not close the stream.
Pause and resume this stream automatically on interruptions. Does not start playback by itself. Does not close the stream.
Pause and resume this stream automatically on interruptions. Does not start playback by itself. Does not close the stream.
Pause and resume this stream automatically on interruptions. Does not start playback by itself. Does not close the stream.
Pause and resume this stream automatically on interruptions. Does not start playback by itself. Does not close the stream.
Provide an Android Context so setActive can request audio focus and so input AudioEngine.openStream can throw PermissionException when android.Manifest.permission.RECORD_AUDIO is missing. Uses Context.getApplicationContext.
Stop listening for route changes.
Stop listening for route changes.
Stop listening for route changes.
Stop listening for route changes.
Stop listening for route changes.
Stop listening for route changes.
Configure the audio session category and mode.
Configure the audio session category and mode.
Configure the audio session category and mode.
Configure the audio session category and mode.
Configure the audio session category and mode.
Configure the audio session category and mode.
Whether microphone permission is currently granted.
Whether microphone permission is currently granted.
Whether microphone permission is currently granted.
Whether microphone permission is currently granted.
Whether microphone permission is currently granted.
Whether microphone permission is currently granted.
Register a listener for audio interruptions (phone calls, focus loss).
Register a listener for audio interruptions (phone calls, focus loss).
Register a listener for audio interruptions (phone calls, focus loss).
Register a listener for audio interruptions (phone calls, focus loss).
Register a listener for audio interruptions (phone calls, focus loss).
Register a listener for audio interruptions (phone calls, focus loss).
Register a listener for audio route change events.
Register a listener for audio route change events.
Register a listener for audio route change events.
Register a listener for audio route change events.
Register a listener for audio route change events.
Register a listener for audio route change events.
Ask the system for microphone permission.
Ask the system for microphone permission.
Ask the system for microphone permission.
Ask the system for microphone permission.
Ask the system for microphone permission.
Ask the system for microphone permission.