com.ooyala.android.offline.OoyalaDownloader Class Reference

A downloader of DASH and HLS media files. More...

Inheritance diagram for com.ooyala.android.offline.OoyalaDownloader:
com.ooyala.android.offline.Downloader com.ooyala.android.offline.DownloadTracker.Listener com.ooyala.android.offline.LicenseDownloader.Listener

Public Member Functions

 OoyalaDownloader (Context context, Cache cache, OoyalaDownloadOptions options)
 Constructor. More...
 
void startDownload ()
 This is to start/resume the download process. More...
 
void cancel ()
 Abort the download. More...
 
float getDownloadPercentage (int taskId)
 
void onDownloadsChanged (DownloadManager downloadManager, DownloadManager.TaskState taskState)
 
void onDownloadsFailed (Throwable ex)
 
void onBitratesObtained (HashMap< String, Integer > bitrates)
 
long getLicenseExpirationDate ()
 Get the license expiration data from the license file. More...
 
void delete (int taskId)
 Completely remove a folder and its contents for an offline video. More...
 
void requestBitrates ()
 Request the represented bitrate list in the manifest. More...
 
void addListener (DownloadListener downloadListener)
 Register a listener to receive events from the downloader. More...
 
void removeListener ()
 Unregister a listener. More...
 
void setOptions (OoyalaDownloadOptions options)
 Set the Ooyala downloader options. More...
 
void onCompleted (String embedCode)
 Called when the license has been downloaded successfully. More...
 
void onFailed (String embedCode, Throwable ex)
 Called when the license download is failed. More...
 
void onDownloadsChanged (DownloadManager downloadManager, TaskState taskState)
 Called when the tracked downloads changed. More...
 

Static Public Member Functions

static DownloadTracker getDownloadTracker (Context context, Cache cache)
 
static DataSource.Factory buildDataSourceFactory (Context context, Cache cache)
 

Detailed Description

A downloader of DASH and HLS media files.

Constructor & Destructor Documentation

com.ooyala.android.offline.OoyalaDownloader.OoyalaDownloader ( Context  context,
Cache  cache,
OoyalaDownloadOptions  options 
)

Constructor.

Parameters
contextA Context.
cacheA Cache implementation that maintains an in-memory representation. Note, only one instance of SimpleCache is allowed for a given directory at a given time.
optionsThe Ooyala downloader options.

Member Function Documentation

void com.ooyala.android.offline.OoyalaDownloader.addListener ( DownloadListener  downloadListener)

Register a listener to receive events from the downloader.

Parameters
downloadListenerThe listener to register.

Implements com.ooyala.android.offline.Downloader.

static DataSource.Factory com.ooyala.android.offline.OoyalaDownloader.buildDataSourceFactory ( Context  context,
Cache  cache 
)
static
Returns
A DataSource.Factory.
void com.ooyala.android.offline.OoyalaDownloader.cancel ( )

Abort the download.

Ooyala will cancel all the pending download tasks. If all segments are downloaded this will be ignored.

Implements com.ooyala.android.offline.Downloader.

void com.ooyala.android.offline.OoyalaDownloader.delete ( int  taskId)

Completely remove a folder and its contents for an offline video.

This is to remove the folder before reuse the same folder name.

Implements com.ooyala.android.offline.Downloader.

float com.ooyala.android.offline.OoyalaDownloader.getDownloadPercentage ( int  taskId)
Parameters
taskIdThe unique task id.
Returns
The estimated download percentage, or C#PERCENTAGE_UNSET if no estimate is available or if this is a removal task.

Implements com.ooyala.android.offline.Downloader.

static DownloadTracker com.ooyala.android.offline.OoyalaDownloader.getDownloadTracker ( Context  context,
Cache  cache 
)
static
Returns
A DownloadTracker.
long com.ooyala.android.offline.OoyalaDownloader.getLicenseExpirationDate ( )

Get the license expiration data from the license file.

This should be called after video files are downloaded in the folder specified.

Returns
the license expiration date, in seconds from epoch. 0 if license file does not exist.

Implements com.ooyala.android.offline.Downloader.

void com.ooyala.android.offline.OoyalaDownloader.onBitratesObtained ( HashMap< String, Integer >  bitrates)
void com.ooyala.android.offline.OoyalaDownloader.onCompleted ( String  embedCode)

Called when the license has been downloaded successfully.

Implements com.ooyala.android.offline.LicenseDownloader.Listener.

void com.ooyala.android.offline.DownloadTracker.Listener.onDownloadsChanged ( DownloadManager  downloadManager,
TaskState  taskState 
)
inherited

Called when the tracked downloads changed.

void com.ooyala.android.offline.OoyalaDownloader.onDownloadsChanged ( DownloadManager  downloadManager,
DownloadManager.TaskState  taskState 
)
void com.ooyala.android.offline.OoyalaDownloader.onDownloadsFailed ( Throwable  ex)
void com.ooyala.android.offline.OoyalaDownloader.onFailed ( String  embedCode,
Throwable  ex 
)

Called when the license download is failed.

Implements com.ooyala.android.offline.LicenseDownloader.Listener.

void com.ooyala.android.offline.OoyalaDownloader.removeListener ( )

Unregister a listener.

The listener will no longer receive events from the downloader.

Implements com.ooyala.android.offline.Downloader.

void com.ooyala.android.offline.OoyalaDownloader.requestBitrates ( )

Request the represented bitrate list in the manifest.

The result will be returned DownloadListener#onBitratesObtained callback.

Implements com.ooyala.android.offline.Downloader.

void com.ooyala.android.offline.OoyalaDownloader.setOptions ( OoyalaDownloadOptions  options)

Set the Ooyala downloader options.

It will override the options that have been set in the constructor.

Implements com.ooyala.android.offline.Downloader.

void com.ooyala.android.offline.OoyalaDownloader.startDownload ( )

This is to start/resume the download process.

All the segments already downloaded will be skipped.

Implements com.ooyala.android.offline.Downloader.