Playing a downloaded asset
The client application can pick a download and retrieve the local URL associated with the download, loading and playing that URL just like a normal CDN-hosted stream. The watch download operation must take place after the start download operation. The download does not need to have completed for this operation to run.
Example code
The following code example shows how to watch the download.
- (void)play:(NMPDownload* )download
{
NSString* url = download.localURI;
NSString* contentID = download.asset.PRMContentID;
NSString* prmSyntax = download.asset.PRMSyntax;
NSString* meta = [_downloadManager getPrivateMetadata:download.UUID];
// check the license, if required.
if(meta.length > 0)
{
NSDictionary* metaDict = [NSJSONSerialization JSONObjectWithData:[meta dataUsingEncoding:NSUTF8StringEncoding] options:0 error:0];
[self drmHandler].currentStream = metaDict;
contentID = metaDict[@"Content_ID"];
}
if (![[self drmHandler] checkLicense: contentID]) {
[[self drmHandler] prefetchLicense: contentID
withPRMSyntax: prmSyntax];
}
[self.playbackVC playWithUrl:[NSURL URLWithString:url]];
}
See the NMPDownloadManager class reference for details of the API calls used above.
Next step: You can purge the download.