iOS Developer Library

Developer

MediaPlayer Framework Reference MPPlayableContentDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

MPPlayableContentDelegate

Inheritance


Not Applicable

Conforms To


Import Statement


Swift

import MediaPlayer

Objective-C

@import MediaPlayer;

Availability


Available in iOS 7.1 and later.

Use the MPPlayableContentDelegate protocol to let external media players send playback commands to an app. After the media player determines that a media item is to be played, the app’s content delegate requests for playback to be initiated.

  • Plays the media item at the specified index.

    Declaration

    Swift

    optional func playableContentManager(_ contentManager: MPPlayableContentManager!, initiatePlaybackOfContentItemAtIndexPath indexPath: NSIndexPath!, completionHandler completionHandler: ((NSError!) -> Void)!)

    Objective-C

    - (void)playableContentManager:(MPPlayableContentManager *)contentManager initiatePlaybackOfContentItemAtIndexPath:(NSIndexPath *)indexPath completionHandler:(void (^)(NSError *))completionHandler

    Parameters

    contentManager

    The content manager that the media item is contained in.

    indexPath

    The index for the indicated item.

    completionHandler

    A block to be called after initiating a playback request.

    The block receives the following parameter:

    error

    Contains an error message if there is an error when beginning playback for the requested item; otherwise, contains nil.

    Discussion

    Call the playableContentManager:initiatePlaybackOfContentItemAtIndexPath:completionHandler: method when a media player interface needs to play a media item. The media player sends to the app the content manager and the index of the requested item. The app responds by supplying the requested media item to the media player.

    Import Statement

    Objective-C

    @import MediaPlayer;

    Swift

    import MediaPlayer

    Availability

    Available in iOS 7.1 and later.