Class VdoDownloadManager
-
- All Implemented Interfaces:
public class VdoDownloadManager
VdoDownloadManager 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 interface
VdoDownloadManager.EventListener
Callback interface for listening to download events.
public interface
VdoDownloadManager.QueryResultListener
Callback interface for listening to query results.
public final class
VdoDownloadManager.Query
Class used to specify filters for a query.
-
Field Summary
Fields Modifier and Type Field Description public final static int
STATUS_NOT_FOUND
public final static int
STATUS_PENDING
public final static int
STATUS_DOWNLOADING
public final static int
STATUS_PAUSED
public final static int
STATUS_COMPLETED
public final static int
STATUS_FAILED
public final static int
STATUS_REMOVING
public final static int
STATUS_RESTARTING
public final static int
PAUSED_EXPLICIT
public final static int
PAUSED_QUEUED_FOR_WIFI
public final static int
PAUSED_UNKNOWN
public final static int
PAUSED_WAITING_FOR_NETWORK
public final static int
PAUSED_WAITING_TO_RETRY
public final static int
ERROR_UNKNOWN
public final static int
ERROR_CANNOT_RESUME
public final static int
ERROR_INVALID_DOWNLOAD_SPEC
public final static int
ERROR_DOWNLOAD_MANAGER
public final static int
ERROR_DOWNLOAD_PERMISSION_MISSING
public final static int
ERROR_UNHANDLED_HTTP_CODE
public final static int
ERROR_SERVER_DENIED
public final static int
ERROR_SERVER_ERROR
public final static int
ERROR_HTTP_DATA_ERROR
public final static int
ERROR_TOO_MANY_REDIRECTS
public final static int
ERROR_FILE_ERROR
public final static int
ERROR_DEVICE_NOT_FOUND
public final static int
ERROR_FILE_ALREADY_EXISTS
public final static int
ERROR_INSUFFICIENT_SPACE
public final static int
ERROR_FILE_PERMISSION_DENIED
public final static int
ERROR_DATABASE
public final static int
ERROR_LICENSE
public final static int
ERROR_LICENSE_PLAY_INTEGRITY_VERIFICATION_FAILED
public final static int
ERROR_LICENSE_NETWORK_CONNECTION_ERROR
public final static int
ERROR_DRM
-
Method Summary
Modifier and Type Method Description static VdoDownloadManager
getInstance(@NonNull() Context context)
Get an instance of VdoDownloadManager. static VdoDownloadManager
getInstance(@NonNull() Context context, @Nullable() String downloadLocation)
Get an instance of VdoDownloadManager. void
setDownloadNotificationHelper(@Nullable() Class<out VdoDownloadNotificationHelper> downloadNotificationHelper)
Change download notification look and feel. void
addEventListener(VdoDownloadManager.EventListener listener)
Add a listener for download events. void
removeEventListener(VdoDownloadManager.EventListener listener)
Remove a listener of download events. void
saveOffline(@NonNull() DownloadRequest downloadRequest)
Enqueue a request to be downloaded. void
enqueueV2(@NonNull() DownloadRequest downloadRequest)
Enqueue a request to be downloaded. void
enqueue(@NonNull() DownloadRequest request)
Enqueue a request to be downloaded. void
query(@NonNull() VdoDownloadManager.Query query, @NonNull() VdoDownloadManager.QueryResultListener queryResultListener)
Query the VdoDownloadManager about media downloads that have been requested. void
getSavedMediaItems(@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. void
remove(Array<String> mediaIds)
Cancel media downloads and delete them locally. void
stopDownload(String mediaId)
void
resumeDownload(String mediaId)
void
stopDownloads(Array<String> mediaIds)
Stop download for given media ids. void
pauseAllDownloads(Array<String> mediaIds)
void
resumeDownloads(Array<String> mediaIds)
Resume download for given media ids. void
resumeAllDownloads(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)
-
-
-
-