User guide

Listing 3-2 An interruption-ended delegate method for an audio player
- (void) audioPlayerEndInterruption: (AVAudioPlayer *) player {
if (interruptedOnPlayback) {
[player prepareToPlay];
[player play];
playing = YES;
interruptedOnPlayback = NO;
}
}
Responding to a Media Server Reset
The media server provides audio and other multimedia functionality through a shared server process. Although
rare, it is possible for the media server to reset while your app is active. Register for the
AVAudioSessionMediaServicesWereResetNotification notification to monitor for a media server
reset. After receiving the notification, your app needs to do the following:
Dispose of orphaned audio object and create new audio objects
Reset any internal audio states being tracked, including all properties of AVAudioSession
When appropriate, reactivate the AVAudioSession using the setActive:error: method
Important: Apps do not need to re-register for any AVAudioSession notifications or reset
key-value-observers on AVAudioSession properties.
You can also register for the AVAudioSessionMediaServicesWereLostNotification notification if you
want to know when the media server first becomes unavailable. However, most apps only need to respond to
the reset notification. Only use the lost notification if the app must respond to user events that occur after the
media server is lost, but before the media server is reset.
Providing Guidelines to the User
A user may not want an app to be interrupted by a competing audio session—for instance, when running an
audio recorder to capture a presentation.
Responding to Interruptions
Responding to a Media Server Reset
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
30