Instance Method

requestPlayerItemForVideo:options:resultHandler:

Requests a representation of the video asset for playback, to be loaded asynchronously.

Declaration

- (PHImageRequestID)requestPlayerItemForVideo:(PHAsset *)asset options:(PHVideoRequestOptions *)options resultHandler:(void (^)(AVPlayerItem *playerItem, NSDictionary *info))resultHandler;

Parameters

asset

The video asset to be played back.

options

Options specifying how Photos should handle the request and notify your app of progress or errors. For details, see PHVideoRequestOptions.

resultHandler

A block Photos calls after loading the asset’s data and preparing the player item.

The block takes the following parameters:

playerItem

An AVPlayerItem object that you can use for playing back the video asset.

info

A dictionary providing information about the status of the request. See Image Result Info Keys for possible keys and values.

Return Value

A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the cancelImageRequest: method.

Discussion

When you call this method, Photos downloads the video data (if necessary) and creates a player item. It then calls your resultHandler block to provide the requested video.

Use this method when you want to simply play back the video asset as it currently exists. For more detailed options or to work with the asset’s audio and video tracks, use the requestAVAssetForVideo:options:resultHandler: method instead.

See Also

Requesting Video Objects

- requestExportSessionForVideo:options:exportPreset:resultHandler:

Requests an export session for writing the video asset’s data to a file, to be loaded asynchronously.

- requestAVAssetForVideo:options:resultHandler:

Requests AVFoundation objects representing the video asset’s content and state, to be loaded asynchronously.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software