AudioSession class

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.

Properties

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

Methods

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 nonexistent method or property is accessed.
inherited
setActive(bool active, {AVAudioSessionSetActiveOptions? avAudioSessionSetActiveOptions, AndroidAudioFocusGainType? androidAudioFocusGainType, AndroidAudioAttributes? androidAudioAttributes, bool? androidWillPauseWhenDucked, AudioSessionConfiguration fallbackConfiguration = const AudioSessionConfiguration.music()}) 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, androidAudioAttributes and androidWillPauseWhenDucked are speficied, they will override the configuration.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

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