Package com.brightcove.player.edge
Class OfflineStoreManager
java.lang.Object
com.brightcove.player.store.BaseStore
com.brightcove.player.edge.OfflineStoreManager
Store manager can be used to persist data into an application specific private database.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic @interfaceAny method attempting to callchangeDownloadIdentifier(Video)must be annotated explicitly with this annotation.
- 
Field SummaryFields inherited from class com.brightcove.player.store.BaseStorecontext, dataStore, MAX_SQL_EXPRESSIONS, MAX_SQL_VARIABLES, source
- 
Method SummaryModifier and TypeMethodDescriptioncom.brightcove.player.store.DownloadRequestSetaddDownloadRequests(com.brightcove.player.store.DownloadRequestSet requestSet, IDownloadManager.IRequest... requests) Creates a new blank download request set.com.brightcove.player.store.OfflineVideochangeDownloadIdentifier(Video video) Changes the download identifier associated with given video.intcountDownloadRequestsInState(Long requestSetKey, int statusCode) Counts the download requests belonging to a DownloadRequestSet with the specified status code.com.brightcove.player.store.DownloadRequestSetcreateDownloadRequestSet(RequestConfig requestConfig, long estimatedSize) Creates a new blank download request set.booleanDeletes the specified request set from the store.booleandeleteOfflineVideo(String videoId) Deletes the first offline video entity with the given video identifier.List<com.brightcove.player.store.OfflineVideo>Finds all offline video entities.List<com.brightcove.player.store.OfflineVideo>findAllOfflineVideo(int status) Finds all offline video entities with the specified statusList<com.brightcove.player.store.DownloadRequest>findCurrentDownloadBatchInProgress(int batchSize) Finds the current set of download request which are still being processed.List<com.brightcove.player.store.DownloadRequestSet>Finds the current set of download request set which are still being processed.com.brightcove.player.store.DownloadRequestSetFinds a download request set with the specified unique key.Collection<com.brightcove.player.store.DownloadRequestSet>findDownloadRequestSets(Long... requestIds) Finds the download request sets to which the given requests belong to.List<com.brightcove.player.store.DownloadRequest>findDownloadsToBeQueued(int batchSize, boolean excludeWifiOnly) Fetches a list of download requests that not have been queued for download by theDownloadManager.android.net.UrifindOfflineAssetUri(android.net.Uri uri) Finds the local URI of a remote asset that has been downloaded successfully.com.brightcove.player.store.OfflineVideofindOfflineVideo(String videoId) Finds the first offline video entity with the given video identifier.static OfflineStoreManagergetInstance(android.content.Context context) Gets reference to the single instance ofOfflineStoreManagerbooleanChecks if the current set of download request are still being processed.booleanisDownloadCompleted(Long requestSetKey) Checks if the DownloadRequestSet is completed.List<com.brightcove.player.store.DownloadRequest>Marks the specified request set for removal.List<com.brightcove.player.store.DownloadRequest>Marks a download request set as paused.<E extends IdentifiableEntity>
 ErefreshEntity(E entity) Refresh the given entity.com.brightcove.player.store.DownloadRequestSetMarks a download request set as waiting to be queued.<T extends IdentifiableEntity>
 TsaveEntity(T entity) Inserts or updates the given entity.com.brightcove.player.store.OfflineVideosaveOfflineLicense(Video video) Updates the entity with given unique video identifier to save the video license information.com.brightcove.player.store.OfflineVideosaveOfflineVideo(Video video) Updates the entity with given unique video identifier to save the video metadata object, while retaining the previously saved license information.com.brightcove.player.store.OfflineVideosaveOfflineVideo(Video video, File downloadDirectory, com.brightcove.player.store.DownloadRequestSet requestSet) Saves the offline video information into the store.toVideoList(List<com.brightcove.player.store.OfflineVideo> entityList) Converts the given list ofOfflineVideoobjects into a list ofVideoobjects.booleanupdateDownloadId(Long key, Long downloadId) Sets the download identifier for the request with the specified primary key.com.brightcove.player.store.OfflineVideoupdateDownloadRequestIdList(String videoId, List<Long> requestIdList, long estimatedSize) Updates the entity with given unique video identifier to save the current list of download request identifiers.booleanupdateDownloadRequestSetStatus(com.brightcove.player.store.DownloadRequestSet requestSet, int statusCode, int reasonCode, com.brightcove.player.store.DownloadRequest downloadRequest, boolean evaluateAllSegments) Updates the status of Download Request Set.com.brightcove.player.store.DownloadRequestupdateDownloadRequestStatusByDownloadId(Long downloadId, int statusCode, int reasonCode, long bytesDownloaded, long actualSize, boolean updateParentRecord) Updates the status of download request.Methods inherited from class com.brightcove.player.store.BaseStorecompact, deleteEntity, getDefaultDatabaseName, getDefaultDatabasePassword, getFileSize, onCreated, onUpgraded
- 
Method Details- 
getInstanceGets reference to the single instance ofOfflineStoreManager- Parameters:
- context- reference to the host application context.
- Returns:
- reference to the OfflineStoreManager
 
- 
refreshEntityRefresh the given entity. This refreshes the already loaded properties in the entity. If no properties are loaded then the default properties will be loaded.- Overrides:
- refreshEntityin class- BaseStore
- Type Parameters:
- E- the expected type of the entity;
- Parameters:
- entity- reference to the entity to be refreshed.
- Returns:
- null if the entity is null or if it does not exist in the store, otherwise reference to the updated entity
 
- 
saveEntityInserts or updates the given entity.- Overrides:
- saveEntityin class- BaseStore
- Parameters:
- entity- the entity to be save.
- Returns:
- the updated the entity.;
 
- 
updateDownloadRequestIdList@Nullable public com.brightcove.player.store.OfflineVideo updateDownloadRequestIdList(@NonNull String videoId, @Nullable List<Long> requestIdList, long estimatedSize) Updates the entity with given unique video identifier to save the current list of download request identifiers.- Parameters:
- videoId- the unique video identifier.
- requestIdList- a list of download request identifiers.
- Returns:
- null if an entity with specified video identifier was found, otherwise reference to the updated entity.
 
- 
saveOfflineVideopublic com.brightcove.player.store.OfflineVideo saveOfflineVideo(@NonNull Video video, @NonNull File downloadDirectory, @NonNull com.brightcove.player.store.DownloadRequestSet requestSet) Saves the offline video information into the store.- Parameters:
- video- the video information to be saved.
- downloadDirectory- the download directory for this video.
- requestSet- the download request set related to this video.
- Returns:
- reference to the newly created entity.
 
- 
saveOfflineVideoUpdates the entity with given unique video identifier to save the video metadata object, while retaining the previously saved license information.- Parameters:
- video- the video to be saved.
- Returns:
- reference to the updated entity.
- See Also:
 
- 
saveOfflineLicenseUpdates the entity with given unique video identifier to save the video license information.- Parameters:
- video- the video to be saved.
- Returns:
- reference to the updated entity.
- See Also:
 
- 
findOfflineVideoFinds the first offline video entity with the given video identifier.- Parameters:
- videoId- the unique video identifier.
- Returns:
- null if there is no offline entity with the given identifier, otherwise reference to first matching entity.
 
- 
findAllOfflineVideoFinds all offline video entities.- Returns:
- a list of offline video entities.
 
- 
findAllOfflineVideoFinds all offline video entities with the specified status- Returns:
- a list of offline video entities.
 
- 
deleteOfflineVideoDeletes the first offline video entity with the given video identifier.- Parameters:
- videoId- the unique video identifier.
- Returns:
- true if a matching entity was found and deleted, otherwise false.
 
- 
createDownloadRequestSet@NonNull public com.brightcove.player.store.DownloadRequestSet createDownloadRequestSet(@Nullable RequestConfig requestConfig, long estimatedSize) Creates a new blank download request set.- Returns:
- reference to the newly created entity
 
- 
addDownloadRequests@NonNull public com.brightcove.player.store.DownloadRequestSet addDownloadRequests(@NonNull com.brightcove.player.store.DownloadRequestSet requestSet, @NonNull IDownloadManager.IRequest... requests) Creates a new blank download request set.- Returns:
- reference to the newly created entity
 
- 
findDownloadRequestSetByKey@Nullable public com.brightcove.player.store.DownloadRequestSet findDownloadRequestSetByKey(@NonNull Long key) Finds a download request set with the specified unique key.- Parameters:
- key- the primary key of the request set.
- Returns:
- null if the entity was not found, otherwise reference to the entity.
 
- 
findOfflineAssetUri@Nullable public android.net.Uri findOfflineAssetUri(@Nullable android.net.Uri uri) Finds the local URI of a remote asset that has been downloaded successfully.- Parameters:
- uri- the remote URI to the asset.
- Returns:
- null if the asset is not available, otherwise URI to the local copy of the asset.
 
- 
findDownloadRequestSetspublic Collection<com.brightcove.player.store.DownloadRequestSet> findDownloadRequestSets(@NonNull Long... requestIds) Finds the download request sets to which the given requests belong to.- Parameters:
- requestIds- an array of one or more download requests.
- Returns:
- a list of download request sets.
 
- 
deleteDownloadRequestSetDeletes the specified request set from the store.- Parameters:
- key- the primary key of the request set to be deleted.
- Returns:
- true if a matching entity was found and deleted, otherwise false.
 
- 
updateDownloadRequestStatusByDownloadId@Nullable public com.brightcove.player.store.DownloadRequest updateDownloadRequestStatusByDownloadId(@NonNull Long downloadId, int statusCode, int reasonCode, long bytesDownloaded, long actualSize, boolean updateParentRecord) Updates the status of download request.- Parameters:
- downloadId- the unique identifier of the download request that caused the status change.
- statusCode- the new status of the download.
- reasonCode- the reason code for the new status, if any.
- bytesDownloaded- the number of bytes downloaded so far.
- actualSize- the total size of the download.
- updateParentRecord- true to update the DownloadRequestSet parent record.
- Returns:
- reference to the updated entity if it was found and updated, otherwise null.
 
- 
updateDownloadRequestSetStatuspublic boolean updateDownloadRequestSetStatus(com.brightcove.player.store.DownloadRequestSet requestSet, int statusCode, int reasonCode, com.brightcove.player.store.DownloadRequest downloadRequest, boolean evaluateAllSegments) Updates the status of Download Request Set.- Parameters:
- requestSet- the Download Request Set
- statusCode- the new status of the download segment.
- reasonCode- the reason code for the new status, if any.
- downloadRequest- the new segment Download Request
- evaluateAllSegments- if true, it makes sure to evaluate all download request segments to get the overall status.
- Returns:
- true if updated.
 
- 
pauseDownloadRequestSet@NonNull public List<com.brightcove.player.store.DownloadRequest> pauseDownloadRequestSet(@NonNull Long key) Marks a download request set as paused.- Parameters:
- key- the primary key of the request set to be paused.
- Returns:
- a list of download requests that have to be removed from the active download queue.
 
- 
resumeDownloadRequestSet@Nullable public com.brightcove.player.store.DownloadRequestSet resumeDownloadRequestSet(@NonNull Long key) Marks a download request set as waiting to be queued.- Parameters:
- key- the primary key of the request set to be paused.
- Returns:
- null if the request set was not found, otherwise reference to the updated request set.
 
- 
updateDownloadIdSets the download identifier for the request with the specified primary key.- Parameters:
- key- the primary key of the request to be updated.
- downloadId- the unique identifier to the download request in the- DownloadManager
- Returns:
- true if the entity was found and updated, otherwise false.
 
- 
changeDownloadIdentifier@Nullable public com.brightcove.player.store.OfflineVideo changeDownloadIdentifier(@NonNull Video video) Changes the download identifier associated with given video. This method is intended for internal use only. Please do not call this in the application project.- Parameters:
- video- reference to the video.
- Returns:
- the offline video entity associated with this video, if any.
 
- 
markRequestSetForRemoval@NonNull public List<com.brightcove.player.store.DownloadRequest> markRequestSetForRemoval(@NonNull Long key) Marks the specified request set for removal. A request set that has been marked for removal will not be queued or checked for further status changes. Any download requests in the set that has been queued already will be removed. The request set itself will be deleted once all the requests have been removed.- Parameters:
- key- the primary key of the request set to be updated.
- Returns:
- a list download requests that must be removed from the download queue.
 
- 
findDownloadsToBeQueued@NonNull public List<com.brightcove.player.store.DownloadRequest> findDownloadsToBeQueued(int batchSize, boolean excludeWifiOnly) Fetches a list of download requests that not have been queued for download by theDownloadManager.- Parameters:
- batchSize- the maximum number of entities to fetch.
- excludeWifiOnly- true if the requests that allowed only on wifi networks must be excluded, otherwise false.
- Returns:
- a list of pending download requests.
 
- 
isCurrentDownloadBatchInProgresspublic boolean isCurrentDownloadBatchInProgress()Checks if the current set of download request are still being processed.- Returns:
- true if the current set of download request are still being processed, otherwise false.
 
- 
countDownloadRequestsInStateCounts the download requests belonging to a DownloadRequestSet with the specified status code.- Parameters:
- requestSetKey- the Download Request Set key.
- statusCode- the status code.
- Returns:
- the count.
 
- 
isDownloadCompletedChecks if the DownloadRequestSet is completed.- Parameters:
- requestSetKey- the Download Request Set key.
- Returns:
- true is download is completed.
 
- 
findCurrentDownloadBatchInProgresspublic List<com.brightcove.player.store.DownloadRequest> findCurrentDownloadBatchInProgress(int batchSize) Finds the current set of download request which are still being processed.- Parameters:
- batchSize- the maximum number of entities to fetch
- Returns:
- a list of download requests
 
- 
findCurrentDownloadRequestSetInProgresspublic List<com.brightcove.player.store.DownloadRequestSet> findCurrentDownloadRequestSetInProgress()Finds the current set of download request set which are still being processed.- Returns:
- a list of download request sets
 
- 
toVideoListpublic static List<Video> toVideoList(@NonNull List<com.brightcove.player.store.OfflineVideo> entityList) Converts the given list ofOfflineVideoobjects into a list ofVideoobjects.- Parameters:
- entityList- the list to be converted.
- Returns:
- the converted list.
 
 
-