iOS Developer Library

Developer

MediaPlayer Framework Reference MPPlayableContentDataSource Protocol Reference

Options
Deployment Target:

On This Page
Language:

MPPlayableContentDataSource

Inheritance


Not Applicable

Import Statement


Swift

import MediaPlayer

Objective-C

@import MediaPlayer;

Availability


Available in iOS 7.1 and later.

To support external media players, create a class that conforms to the MPPlayableContentDataSource protocol. When your app launches, create an instance of this class and assign it to the shared MPPlayableContentManagerdataSource property. This data source provides media metadata to external media players so that they can build user interfaces displaying your app’s content. It is best to set this data source as early as possible in your app’s lifecycle, as iOS may start asking for content right away.

  • Retrieves the media item at the specified index. (required)

    Declaration

    Swift

    func contentItemAtIndexPath(_ indexPath: NSIndexPath!) -> MPContentItem!

    Objective-C

    - (MPContentItem *)contentItemAtIndexPath:(NSIndexPath *)indexPath

    Parameters

    indexPath

    The index for the media item to be retrieved.

    Return Value

    An MPContentItem object containing the media item at the indicated index.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • Starts to load the children of the indicated index.

    Declaration

    Swift

    optional func beginLoadingChildItemsAtIndexPath(_ indexPath: NSIndexPath!, completionHandler completionHandler: ((NSError!) -> Void)!)

    Objective-C

    - (void)beginLoadingChildItemsAtIndexPath:(NSIndexPath *)indexPath completionHandler:(void (^)(NSError *))completionHandler

    Parameters

    indexPath

    The index of the current item.

    completionHandler

    A block to be called after all loading is completed.

    The block receives the following parameter:

    error

    Contains an error message if there was an error trying to load the children of the indicated item; otherwise, contains nil.

    Discussion

    Call the beginLoadingChildItemsAtIndexPath:completionHandler: method to start asynchronous batch loading of media items. The app can load content before the media player needs to display the next media items. When you use this method, the client app must call the completion handler after loading has finished.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • Returns a Boolean value indicating whether the provided content supports playback progress.

    Declaration

    Swift

    optional func childItemsDisplayPlaybackProgressAtIndexPath(_ indexPath: NSIndexPath!) -> Bool

    Objective-C

    - (BOOL)childItemsDisplayPlaybackProgressAtIndexPath:(NSIndexPath *)indexPath

    Parameters

    indexPath

    The index of the media item being queried.

    Return Value

    Returns TRUE if the indicated media item supports displaying playback progress.

    Discussion

    If you don’t implement the childItemsDisplayPlaybackProgressAtIndexPath: method playback progress is not supported for any media item. If any media item does support displaying the playback progress, you must implement this method.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.

  • Provides the number of child nodes for the indicated node. (required)

    Declaration

    Swift

    func numberOfChildItemsAtIndexPath(_ indexPath: NSIndexPath!) -> Int

    Objective-C

    - (NSInteger)numberOfChildItemsAtIndexPath:(NSIndexPath *)indexPath

    Parameters

    indexPath

    The index for the node to be queried.

    Return Value

    An NSIntegervalue representing the number of child nodes associated with the indicated node.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.