AudioSession AudioSession Class

Definition

Interface to to control the audio context of your application

[ObjCRuntime.Deprecated(ObjCRuntime.PlatformName.iOS, 7, 0, ObjCRuntime.PlatformArchitecture.None, "Use 'AVAudioSession' instead.")]
public static class AudioSession
type AudioSession = class
Inheritance
AudioSessionAudioSession
Attributes

Remarks

Both the AVAudioSession and AVAudioSession reference the same underlying singleton object. Properties in AVAudioSession were deprecated in iOS 7.0, and AVAudioSession appears to be the preferred path forward.

You use the various AudioSession methods to control how the input and output are handled by the operating system, configure the recorder and speakers, control where the audio is played to, and where the audio is recorded from. AudioSession also provides a mechanism to start and stop using the audio system and to monitor changes to the audio system.

Both the initialization sequence and the use of some properties on AudioSession can throw an AudioSessionException.

Your application can use the AddListener(AudioSessionProperty, AudioSession+PropertyListener) method with the AudioInputAvailable value to monitor when the microphone becomes available.

Properties

AudioInputAvailable AudioInputAvailable

Determines whether audio input is available.

AudioRoute AudioRoute

Obsolete method.

AudioShouldDuck AudioShouldDuck

Controls audio ducking for your application.

Category Category

Controls how the operating system treats the audio from your application.

CurrentHardwareInputLatency CurrentHardwareInputLatency

The current hardware input latency in seconds.

CurrentHardwareInputNumberChannels CurrentHardwareInputNumberChannels

The number of hardware input channels.

CurrentHardwareIOBufferDuration CurrentHardwareIOBufferDuration

The size in seconds of the hardware input and output buffer.

CurrentHardwareOutputLatency CurrentHardwareOutputLatency

The current hardware output latency in seconds.

CurrentHardwareOutputNumberChannels CurrentHardwareOutputNumberChannels

Number of hardware output channels.

CurrentHardwareOutputVolume CurrentHardwareOutputVolume

Your application volume, from 0 to 1.

CurrentHardwareSampleRate CurrentHardwareSampleRate

The current hardware sample rate.

InputGainAvailable InputGainAvailable

Determines whether input gain is available.

InputGainScalar InputGainScalar

Input gain as a floating point value from 0 to 1.

InputRoute InputRoute

Controls the source for audio input.

InputSources InputSources

Audio input sources available from a USB connection.

InterruptionType InterruptionType

The type of interruption, used to determine the appropriate course of action when the AudioSession is interrupted.

Mode Mode

Configuration modes for Audio, it provides finer control over the Category property.

OtherAudioIsPlaying OtherAudioIsPlaying

Whether another application is currently playing back audio.

OutputDestinations OutputDestinations

Output destinations

OutputRoutes OutputRoutes

Retrives information about the available audio output routes.

OverrideCategoryDefaultToSpeaker OverrideCategoryDefaultToSpeaker

Controls whether the audio should be routed to the speaker if no headset is plugged.

OverrideCategoryEnableBluetoothInput OverrideCategoryEnableBluetoothInput

If input is coming from a bluetooth headset, it routes the audio output to the headset.

OverrideCategoryMixWithOthers OverrideCategoryMixWithOthers

Mixes the background audio with the audio generated by the application, regardless of the default Category setting.

PreferredHardwareIOBufferDuration PreferredHardwareIOBufferDuration

Your application desired buffer size in seconds.

PreferredHardwareSampleRate PreferredHardwareSampleRate

Your desired audio sample rate.

RoutingOverride RoutingOverride

Controls the output route, overriding the default set by the Category.

Methods

AddListener(AudioSessionProperty, AudioSession+PropertyListener) AddListener(AudioSessionProperty, AudioSession+PropertyListener)

Developers should not use this deprecated method.

Initialize() Initialize()

Initializes the Audio Session.

Initialize(CFRunLoop, String) Initialize(CFRunLoop, String)

Initializes the Audio Session.

RemoveListener(AudioSessionProperty, AudioSession+PropertyListener) RemoveListener(AudioSessionProperty, AudioSession+PropertyListener)

Removes the specified listener from the list of monitored audio session properties.

SetActive(Boolean) SetActive(Boolean)

Enables or Disables the audio session.

SetActive(Boolean, AudioSessionActiveFlags) SetActive(Boolean, AudioSessionActiveFlags)

Activates or deactivates the audio session.

Events

AudioInputBecameAvailable AudioInputBecameAvailable
AudioRouteChanged AudioRouteChanged

Event raised when the input and output audio routes change on the device.

CurrentHardwareOutputVolumeChanged CurrentHardwareOutputVolumeChanged
InputGainBecameAvailable InputGainBecameAvailable
InputGainScalarChanged InputGainScalarChanged
InputSourcesChanged InputSourcesChanged
Interrupted Interrupted

Event raised when the audio session has been interrupted.

OutputDestinationsChanged OutputDestinationsChanged
Resumed Resumed

Event raised when the audio session has resumed.

ServerDied ServerDied

Applies to

See also