Watching downloaded content
The client application picks a download and retrieves 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) / NMP_MEDIA_ERROR_IO
(-1004).
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 OpenTV Player SDK cannot provide an accurate seekable range when the content is downloaded by the application directly. It 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.
Example code
The following code 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());
Next step: Purge the download