AudioSession class Null safety

Manages a single audio session to be used across different audio plugins in your app. AudioSession will configure your app by describing to the operating system the nature of the audio that your app intends to play.

You obtain the singleton instance of this class, configure it during your app's startup, and then use other plugins to play or record audio. An app will typically not call setActive directly since individual audio plugins will call this before they play or record audio.


androidAudioAttributes AndroidAudioAttributes?
The configured AndroidAudioAttributes.
androidAudioFocusGainType AndroidAudioFocusGainType?
The configured AndroidAudioFocusGainType.
becomingNoisyEventStream Stream<void>
A stream of events that occur when audio becomes noisy (e.g. due to unplugging the headphones).
configuration AudioSessionConfiguration?
The current configuration.
configurationStream Stream<AudioSessionConfiguration>
A stream broadcasting the current configuration.
devicesChangedEventStream Stream<AudioDevicesChangedEvent>
A stream emitting events whenever devices are added or removed to the set of available devices.
devicesStream Stream<Set<AudioDevice>>
A stream emitting the set of connected devices whenever there is a change.
hashCode int
The hash code for this object. [...]
read-only, inherited
interruptionEventStream Stream<AudioInterruptionEvent>
A stream of AudioInterruptionEvents.
isConfigured bool
Whether the audio session is configured.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


configure(AudioSessionConfiguration configuration) Future<void>
Configures the audio session. It is useful to call this method during your app's initialisation before you start playing or recording any audio. However, you may also call this method afterwards to change the current configuration at any time.
getDevices({bool includeInputs = true, bool includeOutputs = true}) Future<Set<AudioDevice>>
Completes with a list of available audio devices.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
setActive(bool active, {AVAudioSessionSetActiveOptions? avAudioSessionSetActiveOptions, AndroidAudioFocusGainType? androidAudioFocusGainType, AndroidAudioAttributes? androidAudioAttributes, bool? androidWillPauseWhenDucked, AudioSessionConfiguration fallbackConfiguration = const}) Future<bool>
Activates or deactivates this audio session. Typically an audio plugin should call this method when it begins playing audio. If the audio session is not yet configured at the time this is called, the fallbackConfiguration will be set. If any of avAudioSessionSetActiveOptions, androidAudioFocusGainType, androidAudioAttributesttributes and androidWillPauseWhenDucked are speficied, they will override the configuration.
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Properties

instance Future<AudioSession>
The singleton instance across all Flutter engines.