iOS Developer Library

Developer

MediaPlayer Framework Reference MPPlayableContentManager Class Reference

Options
Deployment Target:

On This Page
Language:

MPPlayableContentManager

Inheritance


Conforms To


Import Statement


Swift

import MediaPlayer

Objective-C

@import MediaPlayer;

Availability


Available in iOS 7.1 and later.

Use the MPPlayableContentManager class to control interactions between a media app and 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 send nonmedia remote playback commands to the app.

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, you need to immediately set the dataSource and delegate properties. Once these properties are set, use the beginUpdates and endUpdates methods to load the information from the data source.

  • 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.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    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.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    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.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    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.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • delegate delegate Property

    A delegate that lets the media player relay nonmedia remote playback commands to the app.

    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. Use the MPRemoteCommandEvent class to respond to events that affect the playback state of the currently playing item. The app must be able to respond to these events at any time.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    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.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.