User guide
Objective-CSwift
Movie players let you play movies from a file or a network stream. Music players let you play audio content
from a user’s music library. To use these objects in coordination with your app audio, consider their audio
session characteristics.
●
Music players (instances of the MPMusicPlayerController class) always use a system-supplied audio
session.
●
Movie players (instances of the MPMoviePlayerController class) use your app’s audio session by
default, but can be configured to use a system-supplied audio session.
Working with Music Players
To play audio from a user’s music library along with your own sounds (as described in iPod Library Access
Programming Guide ), you use the AVAudioSessionCategoryAmbient category, a so-called mixable category
configuration for your audio session, or the AVAudioSessionCategoryOptionMixWithOthers option with
a compatible category. Using this category ensures that your sounds will not interrupt a music player—nor
will a music player’s sounds interrupt yours.
Important: Do not attempt to use a music player without configuring a mixable category for your audio
session.
The system automatically handles route changes and interruptions for music players. You cannot influence
this built-in behavior. As long as you correctly manage your app’s audio session as described here and in
previous chapters, you can rely on a music player to take care of itself, as a user plugs in a headset, an alarm
sounds, or a phone call arrives.
You can configure your audio session so that sound from a music player ducks (lowers in volume) when audio
from your app plays. For details on ducking and how to enable it, see Fine-Tuning a Category (page 24).
For a description of the music player class, see MPMusicPlayerController Class Reference.
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
40
Fine-Tuning an Audio Session for Players