The diagram below outlines how the client application can start the playback of a download. 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, however, need to be have completed for this operation to run.
If an Android M user declined the
WRITE_EXTERNAL_STORAGE permission, media playback will fail with an
NMPVideoView.onErrorListener, receiving a media error of type
MediaPlayer.MEDIA_ERROR_UNKNOWN (1) /
Playback while downloading
The application decides when the user can start playback of an ongoing download. If the application allows playback to be started, it must be careful about seeking or playing past downloaded data.
The Player SDK cannot provide an accurate seekable range when the content is downloaded by the application directly. The Player SDK does, however, provide the asset duration as the upper boundary. If the playback position goes past the current download position, either by seeking or playing, the playback will stop with an error.
The following code example shows how to watch the download:
//Get the download object by Universal Unique ID. Download download = mDownloadManager.getDownloadByUUID(uuid); //Set the local path to NMPVideoView. nmpVideoView.setVideoPath(download.getlocalURI());
Download class reference for details of the API calls used above.