|
Android OpenTV Player SDK
5.23.0.1662114598
|
This class offers the downloading and the storage management of adaptive streaming assets.
The client application can register, start, pause or remove the download of assets. Information pertaining to the downloads can be queried. The queries extract snapshots of the downloads in the form of one or more OTVDownloadItem objects.
Before usage, the DownloadManager must be provided with a storage path and an IDownloadListener interfacing object. Once the path has been set and one IDownloadListener has been registered, the client application can start registering downloads. Downloads registered to the DownloadManager will immediately attempt to access the network and retrieve metadata pertaining to the asset requested, but the raw media data will not be downloaded before the download is explicitly started by the client application.
The preparing and downloading are driven by the callbacks of IDownloadListener.
Objects of this class can be instantiated multiple times, but all instances will point to a single underlying database maintaining all ongoing or finished downloads. The lifecycle of downloads are directly linked to the DownloadManager.
The DownloadManager currently supports the following adaptive streaming protocols and protocol versions :
To setup the DownloadManager, the client application must do the following :
DownloadManager manager = new DownloadManager();manager.setStorage("/path/to/my/desired/storage");manager.registerDownloadStateListener(myListener);...
The DownloadManager can also be configured to perform metadata refreshes when a download items is resumed, enabling this functionality can be useful where the remote content is load balanced and the ideal server may have changed since the download was paused. By default, this functionality is disabled. To do this, the client application must do the following :
DownloadManager manager = new DownloadManager(context, true); // true parameter addedmanager.setStorage("/path/to/my/desired/storage");manager.registerDownloadStateListener(myListener);...
To create a download and start it, the client application can do the following :
String contentURL = "http://somewhere.out.there/on/a/cdn/index.m3u8";String uuid = manager.registerDownload(contentURL);manager.setPrivateData(uuid, MyPrivateJSONString);manager.startDownload(uuid);...
Public Member Functions | |
| OTVDownloadManager (Context xContext) | |
| Creates the OTVDownloadManager. More... | |
| boolean | registerDownloadStateListener (OTVDownloadListener xListener) |
| Register an OTVDownloadListener interface object to receive callbacks around downloads being added / removed, download state changes and download progress. More... | |
| boolean | unregisterDownloadStateListener (OTVDownloadListener xListener) |
| Unregister an OTVDownloadListener interface object that has been previously added by registerDownloadListener. More... | |
| boolean | setStorage (String xPath) |
| Provide the storage area to the DownloadManager. More... | |
| String | getStorage () |
| Retrieve the storage area currently in use by the DownloadManager. More... | |
| String | registerDownload (String xUrl) |
| Register a content to be downloaded to the OTVDownloadManager. More... | |
| String | registerDownload (@NonNull String xUrl,@Nullable OTVMediaDrmCallback xMediaDrmCallback, int xContentType) |
| Register a content to be downloaded to the OTVDownloadManager, explicitly specifying content type. More... | |
| String | registerDownload (String xUrl,@Nullable OTVMediaDrmCallback xMediaDrmCallback) |
| Register a content to be downloaded to the OTVDownloadManager. More... | |
| OTVDownloadItem[] | getDownloadItems () |
| Returns all downloads currently registered in the OTVDownloadManager. More... | |
| OTVDownloadItem | getDownloadByUUID (String xUUID) |
| Returns the download registered to the OTVDownloadManager matching the UUID specified in parameter. More... | |
| boolean | removeDownload (String xUUID) |
| Removes the download specified in parameter. More... | |
| boolean | startDownload (String xUUID, int xBitrate) |
| Starts the download specified in parameter. More... | |
| boolean | pauseDownload (String xUUID) |
| Pauses the running download specified in parameter. More... | |
| boolean | resumeDownload (String xUUID) |
| Resumes the paused download specified in parameter. More... | |
| void | setPrivateMetadata (String xUUID, String xMetadata) |
| Associate a private string to the download. More... | |
| String | getPrivateMetadata (String xUUID) |
| Returns the private string previously associated to the download. More... | |
| boolean | renewLicense (String xUUID,@NonNull OTVMediaDrmCallback xMediaDrmCallback) |
| Renew the widevine license for Dash encrypted stream. More... | |
| OTVDownloadManager | ( | Context | xContext | ) |
Creates the OTVDownloadManager.
| xContext | The application context for the OTVDownloadManager to use |
| OTVDownloadItem getDownloadByUUID | ( | String | xUUID | ) |
Returns the download registered to the OTVDownloadManager matching the UUID specified in parameter.
| xUUID | Universal Unique ID of the download |
| OTVDownloadItem [] getDownloadItems | ( | ) |
Returns all downloads currently registered in the OTVDownloadManager.
| String getPrivateMetadata | ( | String | xUUID | ) |
Returns the private string previously associated to the download.
| xUUID | Universal Unique ID of the download |
null if no string has ever been set. | String getStorage | ( | ) |
Retrieve the storage area currently in use by the DownloadManager.
| boolean pauseDownload | ( | String | xUUID | ) |
Pauses the running download specified in parameter.
The download will change to the STATE_PAUSED state.
| xUUID | Universal Unique ID of the download |
true if the action succeeded; false otherwise. | String registerDownload | ( | String | xUrl | ) |
Register a content to be downloaded to the OTVDownloadManager.
| xUrl | The URL to the manifest of an adaptive streaming asset. |
null if the download could not be registered. | String registerDownload | ( | @NonNull String | xUrl, |
| @Nullable OTVMediaDrmCallback | xMediaDrmCallback, | ||
| int | xContentType | ||
| ) |
Register a content to be downloaded to the OTVDownloadManager, explicitly specifying content type.
| xUrl | The URL to the manifest of an adaptive streaming asset. |
| xMediaDrmCallback | Callback used in offline license acquisition if the content is encrypted |
| xContentType | indicate the stream content type. The available values are: |
null if the download could not be registered. | String registerDownload | ( | String | xUrl, |
| @Nullable OTVMediaDrmCallback | xMediaDrmCallback | ||
| ) |
Register a content to be downloaded to the OTVDownloadManager.
| xUrl | The URL to the manifest of an adaptive streaming asset. |
| xMediaDrmCallback | Callback used in offline license acquisition if the content is encrypted |
null if the download could not be registered. | boolean registerDownloadStateListener | ( | OTVDownloadListener | xListener | ) |
Register an OTVDownloadListener interface object to receive callbacks around downloads being added / removed, download state changes and download progress.
| xListener | and OTVDownloadListener interfacing object to receive callbacks |
| boolean removeDownload | ( | String | xUUID | ) |
Removes the download specified in parameter.
The download will disappear from the list of downloads and be unregistered from OTVDownloadManager. onDownloadRemoved() will be fired when effective.
| xUUID | Universal Unique ID of the download |
true if the action succeeded; false if the UUID does not exist or there is no permission to remove the download (Android M onwards). | boolean renewLicense | ( | String | xUUID, |
| @NonNull OTVMediaDrmCallback | xMediaDrmCallback | ||
| ) |
Renew the widevine license for Dash encrypted stream.
This sync method is used for renew an expired Widevine offline license only. Downloading of license will be automatically handled by SDK. It cannot be called in main thread because there is risk of ANR when license request takes long time.
| xUUID | Universal Unique ID of the download |
| xMediaDrmCallback | Callback used in offline license acquisition |
true if the renew succeeded; false otherwise. | IllegalStateException | If this method is called in main thread |
| boolean resumeDownload | ( | String | xUUID | ) |
Resumes the paused download specified in parameter.
The download will change to the STATE_RUNNING state.
| xUUID | Universal Unique ID of the download |
true if the action succeeded; false if the UUID does not exist or there is no permission to remove the download (Android M onwards). | void setPrivateMetadata | ( | String | xUUID, |
| String | xMetadata | ||
| ) |
Associate a private string to the download.
This allows the client application to associate applicative data with the download. The format is at the developer's convenience. (JSON, XML, ...)
| xUUID | Universal Unique ID of the download |
| xMetadata | String to associate to the download |
| boolean setStorage | ( | String | xPath | ) |
Provide the storage area to the DownloadManager.
This URL should not change over time. If the application developer wishes to move it, it must copy that directory and set a new storage path to the DownloadManager while no downloads are active.
| xPath | Path where the DownloadManager shall store all assets. |
true if the action succeeded; false otherwise. Failure reasons can include: Wrong formatting of the path. | boolean startDownload | ( | String | xUUID, |
| int | xBitrate | ||
| ) |
Starts the download specified in parameter.
The download will change to the STATE_RUNNING state.
| xUUID | Universal Unique ID of the download |
| xBitrate | The consumption bitrate to use with the download. Only bitrates found in OTVDownloadMediaInfo objects are eligible. |
true if the action succeeded; false if the UUID does not exist or there is no permission to remove the download (Android M onwards). | boolean unregisterDownloadStateListener | ( | OTVDownloadListener | xListener | ) |
Unregister an OTVDownloadListener interface object that has been previously added by registerDownloadListener.
| xListener | the listener to unregister |