iOS Developer Library

Developer

Media Player Framework Reference MPPlayableContentManager Class Reference

Options
Deployment Target:

On This Page
Language:

MPPlayableContentManager

Use the MPPlayableContentManager class to control interactions between a media app and system-provided or external media player interfaces. Data is provided by the app to the content manager so that the media player can browse the content provided. A delegate provides the media player the ability to perform actions that manage the app’s playback queue.

You don’t create a new content manager directly, instead you grab the shared content manager using the sharedContentManager method. After getting the shared content manager, your next step depends on the features your app supports:

  • To provide content navigation and suggested content for CarPlay, immediately set both the dataSource and delegate properties. After setting these properties, use the beginUpdates and endUpdates methods to load the information from the data source.

  • To provide suggested content when the user connects headphones, a Bluetooth stereo, or another output device, set only the delegate property. After you set a delegate, iOS automatically calls methods in the MPPlayableContentDelegate protocol allowing you to suggest appropriate content.

  • Updates several Media Player content items at once.

    Declaration

    Swift

    func beginUpdates()

    Objective-C

    - (void)beginUpdates

    Discussion

    Call the beginUpdates method to start a synchronized update of MPContentItems objects, giving developers the ability to perform large batch updates.

    Availability

    Available in iOS 7.1 and later.

  • Ends a synchronized update.

    Declaration

    Swift

    func endUpdates()

    Objective-C

    - (void)endUpdates

    Discussion

    You must call the endUpdates method explicitly when updating is done. If the endUpdates method is called in the middle of an update, all updating stops and any remaining updates must be applied at a later time.

    Availability

    Available in iOS 7.1 and later.

  • Reload the data from the data source.

    Declaration

    Swift

    func reloadData()

    Objective-C

    - (void)reloadData

    Discussion

    Call the reloadData method when the data source has changed. The content manager is notified of the data source change and reloads the data from the data source.

    Availability

    Available in iOS 7.1 and later.

  • The data source provided by the app.

    Declaration

    Swift

    weak var dataSource: MPPlayableContentDataSource?

    Objective-C

    @property(nonatomic, weak) id< MPPlayableContentDataSource > dataSource

    Discussion

    The dataSource property ensures that random access of media items is supported through the MPPlayableContentDataSource protocol because the methods in the protocol can be accessed at any point during the app’s lifetime. Set this property as soon as the data is available.

    Availability

    Available in iOS 7.1 and later.

  • A delegate that lets the media player manage the app’s playback queue.

    Declaration

    Swift

    weak var delegate: MPPlayableContentDelegate?

    Objective-C

    @property(nonatomic, weak) id< MPPlayableContentDelegate > delegate

    Discussion

    The delegate responds to external events that trigger a change in the media item that is currently playing. An example of such an event would be choosing to play a song from a different album, or requesting suggested content to play next. The app must be able to respond to these events at any time.

    To instead respond to events that affect the playback state of the currently playing item, use the MPRemoteCommandEvent class.

    Availability

    Available in iOS 7.1 and later.

  • Returns the current content manager instance.

    Declaration

    Swift

    class func sharedContentManager() -> Self

    Objective-C

    + (instancetype)sharedContentManager

    Return Value

    An MPPlayableContentManager object.

    Discussion

    Call the sharedContentManager method to create a new content manager. Set the dataSource and delegate immediately after creating the content manager.

    Availability

    Available in iOS 7.1 and later.