Class VdoDownloadManager
-
- All Implemented Interfaces:
public class VdoDownloadManagerVdoDownloadManager handles enqueuing download requests and management of media downloads.
New download requests can be added which will remain in queue and downloaded serially.
Status of media downloads can be requested using filtered queries.
Download events can be listened to by registering a listener with the VdoDownloadManager instance. Make sure to unregister listener when not required to avoid memory leaks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceVdoDownloadManager.EventListenerCallback interface for listening to download events.
public interfaceVdoDownloadManager.QueryResultListenerCallback interface for listening to query results.
public final classVdoDownloadManager.QueryClass used to specify filters for a query.
-
Field Summary
Fields Modifier and Type Field Description public final static intSTATUS_NOT_FOUNDpublic final static intSTATUS_PENDINGpublic final static intSTATUS_DOWNLOADINGpublic final static intSTATUS_PAUSEDpublic final static intSTATUS_COMPLETEDpublic final static intSTATUS_FAILEDpublic final static intSTATUS_REMOVINGpublic final static intSTATUS_RESTARTINGpublic final static intPAUSED_EXPLICITpublic final static intPAUSED_QUEUED_FOR_WIFIpublic final static intPAUSED_UNKNOWNpublic final static intPAUSED_WAITING_FOR_NETWORKpublic final static intPAUSED_WAITING_TO_RETRYpublic final static intERROR_UNKNOWNpublic final static intERROR_CANNOT_RESUMEpublic final static intERROR_INVALID_DOWNLOAD_SPECpublic final static intERROR_DOWNLOAD_MANAGERpublic final static intERROR_DOWNLOAD_PERMISSION_MISSINGpublic final static intERROR_UNHANDLED_HTTP_CODEpublic final static intERROR_SERVER_DENIEDpublic final static intERROR_SERVER_ERRORpublic final static intERROR_HTTP_DATA_ERRORpublic final static intERROR_TOO_MANY_REDIRECTSpublic final static intERROR_FILE_ERRORpublic final static intERROR_DEVICE_NOT_FOUNDpublic final static intERROR_FILE_ALREADY_EXISTSpublic final static intERROR_INSUFFICIENT_SPACEpublic final static intERROR_FILE_PERMISSION_DENIEDpublic final static intERROR_DATABASEpublic final static intERROR_LICENSEpublic final static intERROR_LICENSE_PLAY_INTEGRITY_VERIFICATION_FAILEDpublic final static intERROR_LICENSE_NETWORK_CONNECTION_ERRORpublic final static intERROR_DRM
-
Method Summary
Modifier and Type Method Description static VdoDownloadManagergetInstance(@NonNull() Context context)Get an instance of VdoDownloadManager. static VdoDownloadManagergetInstance(@NonNull() Context context, @Nullable() String downloadLocation)Get an instance of VdoDownloadManager. voidsetDownloadNotificationHelper(@Nullable() Class<out VdoDownloadNotificationHelper> downloadNotificationHelper)Change download notification look and feel. voidaddEventListener(VdoDownloadManager.EventListener listener)Add a listener for download events. voidremoveEventListener(VdoDownloadManager.EventListener listener)Remove a listener of download events. voidsaveOffline(@NonNull() DownloadRequest downloadRequest)Enqueue a request to be downloaded. voidenqueueV2(@NonNull() DownloadRequest downloadRequest)Enqueue a request to be downloaded. voidenqueue(@NonNull() DownloadRequest request)Enqueue a request to be downloaded. voidquery(@NonNull() VdoDownloadManager.Query query, @NonNull() VdoDownloadManager.QueryResultListener queryResultListener)Query the VdoDownloadManager about media downloads that have been requested. voidgetSavedMediaItems(@NonNull() VdoDownloadManager.Query query, @NonNull() VdoDownloadManager.QueryResultListener queryResultListener)Query the VdoDownloadManager about media saved for offline playback without drm license. Map<String, Date>getMediaIdLastPlayedTimeMap(Array<String> mediaIds)Returns map of media id and last played time for given media ids. voidremove(Array<String> mediaIds)Cancel media downloads and delete them locally. voidstopDownload(String mediaId)voidresumeDownload(String mediaId)voidstopDownloads(Array<String> mediaIds)Stop download for given media ids. voidpauseAllDownloads(Array<String> mediaIds)voidresumeDownloads(Array<String> mediaIds)Resume download for given media ids. voidresumeAllDownloads(Array<String> mediaIds)-
-
Method Detail
-
getInstance
static VdoDownloadManager getInstance(@NonNull() Context context)
Get an instance of VdoDownloadManager.
- Parameters:
context- a Context- Returns:
VdoDownloadManager instance
-
getInstance
static VdoDownloadManager getInstance(@NonNull() Context context, @Nullable() String downloadLocation)
Get an instance of VdoDownloadManager.
- Parameters:
context- a ContextdownloadLocation- Download Location- Returns:
VdoDownloadManager instance
-
setDownloadNotificationHelper
void setDownloadNotificationHelper(@Nullable() Class<out VdoDownloadNotificationHelper> downloadNotificationHelper)
Change download notification look and feel. Set custom implementation for notifications related to download in progress, completed and failed.
- Parameters:
downloadNotificationHelper- Custom DownloadNotificationHelper ?
-
addEventListener
void addEventListener(VdoDownloadManager.EventListener listener)
Add a listener for download events.
-
removeEventListener
void removeEventListener(VdoDownloadManager.EventListener listener)
Remove a listener of download events.
-
saveOffline
void saveOffline(@NonNull() DownloadRequest downloadRequest)
Enqueue a request to be downloaded. This method provides option to download media items without a DRM license, hence to play these media files one need to set Token and VideoId in com.vdocipher.aegis.player.VdoInitParams with enableOfflinePlayback.
We discourage you from using saveOffline to save media locally without a DRM license and getSavedMediaItems to retrieve these media items. Instead to incorporate offline playback in your app use enqueueV2 to download media items locally and query to retrieve these media items.VdoInitParams vdoParams = new VdoInitParams.Builder() .setToken(mToken) .setVideoId(mVideoId) .enableOfflinePlayback() .build();- Parameters:
downloadRequest- a download request
-
enqueueV2
void enqueueV2(@NonNull() DownloadRequest downloadRequest)
Enqueue a request to be downloaded.
- Parameters:
downloadRequest- a download request
-
enqueue
@Deprecated() void enqueue(@NonNull() DownloadRequest request)
Enqueue a request to be downloaded.
- Parameters:
request- a download request
-
query
void query(@NonNull() VdoDownloadManager.Query query, @NonNull() VdoDownloadManager.QueryResultListener queryResultListener)
Query the VdoDownloadManager about media downloads that have been requested. The results are provided asynchronously to the provided QueryResultListener.
- Parameters:
query- a query specifying filtersqueryResultListener- a listener for the query results
-
getSavedMediaItems
void getSavedMediaItems(@NonNull() VdoDownloadManager.Query query, @NonNull() VdoDownloadManager.QueryResultListener queryResultListener)
Query the VdoDownloadManager about media saved for offline playback without drm license. The results are provided asynchronously to the provided QueryResultListener.
We discourage you from using saveOffline to save media locally without a DRM license and getSavedMediaItems to retrieve those media items. Instead to incorporate offline playback use enqueueV2 to download media item locally and query to retrieve these media items.
- Parameters:
query- a query specifying filtersqueryResultListener- a listener for the query results
-
getMediaIdLastPlayedTimeMap
Map<String, Date> getMediaIdLastPlayedTimeMap(Array<String> mediaIds)
Returns map of media id and last played time for given media ids. Media that has not yet been played will not appear in the result.
- Parameters:
mediaIds- List of media ids.- Returns:
List of media id and last played time pair.
-
remove
void remove(Array<String> mediaIds)
Cancel media downloads and delete them locally.
- Parameters:
mediaIds- mediaIds for media to be removed
-
stopDownload
void stopDownload(String mediaId)
-
resumeDownload
void resumeDownload(String mediaId)
-
stopDownloads
void stopDownloads(Array<String> mediaIds)
Stop download for given media ids.
- Parameters:
mediaIds- List of media id
-
pauseAllDownloads
@Deprecated() void pauseAllDownloads(Array<String> mediaIds)
-
resumeDownloads
void resumeDownloads(Array<String> mediaIds)
Resume download for given media ids.
-
resumeAllDownloads
@Deprecated() void resumeAllDownloads(Array<String> mediaIds)
-
-
-
-