AVAudioSessionDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework/
Availability
Available in iOS 3.0 and later.
Companion guide
Declared in
AVAudioSession.h
Related sample code

Overview

The use of this protocol is deprecated in iOS 6 and later. Instead, you should use the notifications declared in AVAudioSession Class Reference.

The delegate of an AVAudioSession object must adopt the AVAudioSessionDelegate protocol. The methods in this protocol are optional. They allow a delegate to respond to the following sorts of changes in state:

An AVAudioSession delegate can respond to interruptions at the audio session level. You can use this interface along with any iOS audio technology. For example, your AVAudioSession delegate can handle interruptions for OpenAL and audio unit playback.

When using the AV Foundation framework for recording or playback, you can also respond to interruptions at the individual recorder or player level. To do this, create audio recorder or audio player delegates using the protocols described in AVAudioRecorderDelegate Protocol Reference and AVAudioPlayerDelegate Protocol Reference.

Tasks

Delegate Methods

Instance Methods

beginInterruption

Called after your audio session is interrupted.

- (void)beginInterruption
Discussion

By the time this interruption arrives, your audio has already stopped. Your application may be suspended or terminated following an interruption—for example, if a user chooses to take an incoming phone call. Use this method to adjust the user interface, and to save application state, as necessary.

Availability
  • Available in iOS 3.0 and later.
Related Sample Code
Declared In
AVAudioSession.h

endInterruption

Called after your audio session interruption ends.

- (void)endInterruption
Discussion

The endInterruptionWithFlags: method provides you with more information upon interruption end than this method does. Apple recommends that you use endInterruptionWithFlags: instead of this method.

If you implement the endInterruptionWithFlags: method, that method is called instead of this one when an interruption ends.

To resume using audio after an interruption ends, you must ensure that your audio session is active. AVAudioPlayer and AVAudioRecorder instances reactivate your audio session automatically when an interruption ends. If you are using another audio technology, such as OpenAL, audio units, or audio queues, you must reactivate your audio session yourself before you can again use audio.

You can also use this method to update the user interface and application state, as necessary.

Availability
  • Available in iOS 3.0 and later.
Declared In
AVAudioSession.h

endInterruptionWithFlags:

Called after your audio session interruption ends, with flags indicating the state of the audio session.

- (void)endInterruptionWithFlags:(NSUInteger)flags
Parameters
flags

Flags indicating the state of the audio session when this method is called. Flags are described in Interruption Flags.

Discussion

To resume using audio after an interruption ends, you must ensure that your audio session is active. AVAudioPlayer and AVAudioRecorder instances reactivate your audio session automatically when an interruption ends. If you are using another audio technology, such as OpenAL, audio units, or audio queues, you must reactivate your audio session yourself before you can again use audio.

You can also use this method to update the user interface and application state, as necessary.

If this delegate method receives the AVAudioSessionInterruptionFlags_ShouldResume constant in its flags parameter, the audio session is immediately ready to be used.

If you implement this method, it is called instead of the endInterruption method when an interruption ends.

Availability
  • Available in iOS 4.0 and later.
Declared In
AVAudioSession.h

inputIsAvailableChanged:

Called after the availability of audio input changes on a device.

- (void)inputIsAvailableChanged:(BOOL)isInputAvailable
Parameters
isInputAvailable

YES if audio input is now available, or NO if it is not.

Availability
  • Available in iOS 3.0 and later.
Declared In
AVAudioSession.h