Android OpenTV Player SDK
4.23.3.1610362082
|
Public Member Functions | |
boolean | registerDownloadStateListener (IDownloadListener xListener) |
Registers an IDownloadListener object to the DownloadManager. More... | |
boolean | unregisterDownloadStateListener (IDownloadListener xListener) |
Unregisters an IDownloadListener interface from the DownloadManager. 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) |
Registers an asset download to the DownloadManager via its URL. More... | |
Download [] | getDownloads () |
Returns all downloads currently registered in the DownloadManager. More... | |
Download | getDownloadByUUID (String xUUID) |
Returns the download registered to the DownloadManager matching the UUID specified in parameter. More... | |
Download [] | getDownloadByContentId (String xContentId) |
Returns all downloads matching the Content ID 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... | |
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 Download 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);...
Download [] getDownloadByContentId | ( | String | xContentId | ) |
Returns all downloads matching the Content ID specified in parameter.
xContentId | Content ID of the download |
Download getDownloadByUUID | ( | String | xUUID | ) |
Returns the download registered to the DownloadManager matching the UUID specified in parameter.
xUUID | Universal Unique ID of the download |
Download [] getDownloads | ( | ) |
Returns all downloads currently registered in the DownloadManager.
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 | ) |
Registers an asset download to the DownloadManager via its URL.
xUrl | The URL to the master playlist of an adaptive streaming asset. |
null
if the download could not be registered. boolean registerDownloadStateListener | ( | IDownloadListener | xListener | ) |
Registers an IDownloadListener object to the DownloadManager.
All callbacks coming from the DownloadManager will be fired on this interface.
xListener | IDownloadListener interfacing object to register |
true
if the action succeeded; false
otherwise. boolean removeDownload | ( | String | xUUID | ) |
Removes the download specified in parameter.
The download will disappear from the list of downloads and be unregistered from DownloadManager. 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 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 MediaInfo 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 | ( | IDownloadListener | xListener | ) |
Unregisters an IDownloadListener interface from the DownloadManager.
xListener | IDownloadListener interfacing object to unregister |
true
if the action succeeded; false
otherwise.