Bewerken

Delen via


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
AudioSession
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

Determines whether audio input is available.

AudioRoute

Obsolete method.

AudioShouldDuck

Controls audio ducking for your application.

Category

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

CurrentHardwareInputLatency

The current hardware input latency in seconds.

CurrentHardwareInputNumberChannels

The number of hardware input channels.

CurrentHardwareIOBufferDuration

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

CurrentHardwareOutputLatency

The current hardware output latency in seconds.

CurrentHardwareOutputNumberChannels

Number of hardware output channels.

CurrentHardwareOutputVolume

Your application volume, from 0 to 1.

CurrentHardwareSampleRate

The current hardware sample rate.

InputGainAvailable

Determines whether input gain is available.

InputGainScalar

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

InputRoute

Controls the source for audio input.

InputSources

Audio input sources available from a USB connection.

InterruptionType

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

Mode

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

OtherAudioIsPlaying

Whether another application is currently playing back audio.

OutputDestinations

Output destinations

OutputRoutes

Retrives information about the available audio output routes.

OverrideCategoryDefaultToSpeaker

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

OverrideCategoryEnableBluetoothInput

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

OverrideCategoryMixWithOthers

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

PreferredHardwareIOBufferDuration

Your application desired buffer size in seconds.

PreferredHardwareSampleRate

Your desired audio sample rate.

RoutingOverride

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

Methods

AddListener(AudioSessionProperty, AudioSession+PropertyListener)

Developers should not use this deprecated method.

Initialize()

Initializes the Audio Session.

Initialize(CFRunLoop, String)

Initializes the Audio Session.

RemoveListener(AudioSessionProperty, AudioSession+PropertyListener)

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

SetActive(Boolean, AudioSessionActiveFlags)

Activates or deactivates the audio session.

SetActive(Boolean)

Enables or Disables the audio session.

Events

AudioInputBecameAvailable
AudioRouteChanged

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

CurrentHardwareOutputVolumeChanged
InputGainBecameAvailable
InputGainScalarChanged
InputSourcesChanged
Interrupted

Event raised when the audio session has been interrupted.

OutputDestinationsChanged
Resumed

Event raised when the audio session has resumed.

ServerDied

Applies to

See also