BMPOfflineContentManager
Objective-C
@protocol
BMPOfflineContentManager <NSObject, BMPOfflineContentManagerEventHandler>
Swift
protocol OfflineContentManager : OfflineContentManagerEventHandler
Is linked to one SourceConfig and is used to manage offline content and offline DRM related tasks for this single
SourceConfig.
IMPORTANT: Methods from OfflineContentManager need to be called from the main thread.
This class offers functionality to handle the whole lifecycle of protected and unprotected offline content.
Depending on the current state of the SourceConfig, which is represented by offlineState,
different methods are allowed to be called. The table below shows all possible and allowed
transitions between the different states. Each line describes one transition which happens immediately and synchronously.
When there is a method call noted in column “Method call triggering transition”, the “Following State” is entered
immediately after the method call returns.
When there is no method call noted, the “Following State” is entered when the event described in column “OfflineContentManagerListener event” was received.
The “Following State” is always noted under the assumption that no error occurred when calling the transition method,
or during processing of the current task. Errors are always reported to onError(_:,offlineContentManager:). See the
documentation of OfflineContentManagerListener for more information.
Calling any method in an invalid state will not result in any state change.
| Current State | Method call triggering transition | OfflineContentManagerListener event | Following State |
|---|---|---|---|
| NotDownloaded | download | - | Downloading |
| Downloading | cancelDownload | - | Canceling |
| Downloading | suspendDownload | onContentDownloadSuspended | Suspended |
| Downloading | - | onContentDownloadFinished | Downloaded |
| Downloading | - | onContentDownloadProgressChanged | Downloading |
| Downloaded | deleteOfflineData | - | NotDownloaded |
| Suspended | resumeDownload | onContentDownloadResumed | Downloading |
| Suspended | cancelDownload | - | Canceling |
| Canceling | - | onContentDownloadCanceled | NotDownloaded |
| Downloaded | renewOfflineLicense | onOfflineContentLicenseRenewed | Downloaded |
-
The
SourceConfigwhich is managed by thisOfflineContentManagerinstance.Declaration
Objective-C
@property (nonatomic, strong, readonly) BMPSourceConfig *_Nonnull sourceConfig;Swift
var sourceConfig: BMPSourceConfig { get } -
The current offline state for the
SourceConfigwhich is managed by this instance.Declaration
Objective-C
@property (nonatomic, readonly) BMPOfflineState offlineState;Swift
var offlineState: OfflineState { get } -
Returns information containing the remaining DRM license duration and the overall playback license duration.
Note
Only available for FairPlay protected content, whenFairplayConfig.prepareSyncMessageandFairplayConfig.prepareOfflineDrmLicenseInformationare configured while using license server which supports Sync SPC. Will be set when the FairPlay license was retrieved and persisted after starting the download of the asset.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) BMPDrmLicenseInformation *offlineDrmLicenseInformation;Swift
var offlineDrmLicenseInformation: BMPDrmLicenseInformation? { get }Return Value
A new instance of
DrmLicenseInformationrepresenting the according DRM license and playback duration. -
Returns how many bytes of storage are used by the offline content.
Declaration
Objective-C
@property (nonatomic, readonly) long usedStorage;Swift
var usedStorage: Int { get }Return Value
How many bytes of storage are used by the offline content.
-
The
OfflineContentManagerTweaksApifor interactions regarding the tweaks.Declaration
Objective-C
@property (nonatomic, readonly) id<BMPOfflineContentManagerTweaksApi> _Nonnull tweaks; -
Creates and returns a
OfflineSourceConfigwhich should be used with aPlayerinstance when playback of offline content is desired.When intending to create an
OfflineSourceConfigfor DRM protected content, the accordingDrmConfigneeds to be applied to the passed sourceConfig before creating theOfflineSourceConfig.Note
ThumbnailTracks are not respected by this flag.Declaration
Objective-C
- (nullable BMPOfflineSourceConfig *)createOfflineSourceConfig: (BOOL)restrictedToAssetCache;Swift
func createOfflineSourceConfig(restrictedToAssetCache: Bool) -> BMPOfflineSourceConfig?Parameters
restrictedToAssetCacheWhether or not the player should restrict playback only to audio, video and subtitle tracks which are stored offline on the device. This has to be set to
trueif the device has no network access.Return Value
OfflineSourceConfigwhich can be used with aPlayerinstance for offline playback, ornilif no offline content is available. -
Fetches which tracks are available for download. When finished,
OfflineContentManagerListener‘sonAvailableTracksFetched(_:offlineContentManager:): method is called.Declaration
Objective-C
- (void)fetchAvailableTracks;Swift
func fetchAvailableTracks() -
Downloads the media data associated with the managed
SourceConfig.Calling this method is only valid when the
OfflineStateisOfflineStateNotDownloaded. When this method is called with the asset being in a different state it will result in a no-op.Declaration
Objective-C
- (void)download;Swift
func download() -
Downloads the media data associated with the managed
SourceConfig.Calling this method is only valid when the
OfflineStateisOfflineStateNotDownloaded. When this method is called with the asset being in a different state it will result in a no-op.Declaration
Objective-C
- (void)downloadWithDownloadConfig:(nonnull BMPDownloadConfig *)downloadConfig;Swift
func download(downloadConfig: BMPDownloadConfig)Parameters
downloadConfigThe
DownloadConfigused for this download. -
Downloads the media data associated with the managed
SourceConfig.Calling this method is only valid when the
OfflineStateisOfflineStateNotDownloaded. When this method is called with the asset being in a different state it will result in a no-op.Declaration
Objective-C
- (void)downloadWithTracks:(nonnull BMPOfflineTrackSelection *)tracks downloadConfig:(nonnull BMPDownloadConfig *)downloadConfig;Swift
func download(tracks: BMPOfflineTrackSelection, downloadConfig: BMPDownloadConfig)Parameters
downloadConfigThe
DownloadConfigused for this download.tracksThe
OfflineTrackSelectionwith the desired tracks -
Cancels all running download tasks associated with the managed
SourceConfigand deletes the partially downloaded content from disk.Calling this method is only valid when the
offlineStateisOfflineStateDownloadingorOfflineStateSuspended. When this method is called with the asset being in a different state it will result in a no-op.Declaration
Objective-C
- (void)cancelDownload;Swift
func cancelDownload() -
Suspends all running download tasks associated with the managed
SourceConfig.Calling this method is only valid when the
offlineStateisOfflineStateDownloading. When this method is called with the asset being in a different state it will result in a no-op.The download can be resumed by calling
resumeDownload. No data is deleted when calling this method.Declaration
Objective-C
- (void)suspendDownload;Swift
func suspendDownload() -
Resumes all suspended download tasks associated with the managed
SourceConfig.Calling this method is only valid when the
offlineStateisOfflineStateSuspended. When this method is called with the asset being in a different state it will result in a no-op.Declaration
Objective-C
- (void)resumeDownload;Swift
func resumeDownload() -
Deletes the offline stored media data associated with the managed
SourceConfig.Calling this method is only valid when the
offlineStateisOfflineStateDownloaded. When this method is called with the asset being in a different state it will result in a no-op.Declaration
Objective-C
- (void)deleteOfflineData;Swift
func deleteOfflineData() -
Renews the already downloaded DRM license. When successfully finished, the delegate’s
onOfflineContentLicenseRenewed(_:offlineContentManager:)method is called. In case the license renewal fails an according error is passed via the delegate’sonOfflineError(_:offlineContentManager:)method.NOTE: The EXT-X-SESSION-KEY has to be present in the master playlist for this to work properly.
Declaration
Objective-C
- (void)renewOfflineLicense;Swift
func renewOfflineLicense() -
Updates the stored DRM license information (e.g. expiration dates) by querying the KSM. The device needs to be online for this. The
FairPlayConfig.prepareOfflineDrmLicenseInformationblock is called after the KSM was queried successfully.Declaration
Objective-C
- (void)syncOfflineDrmLicenseInformation;Swift
func syncOfflineDrmLicenseInformation()
BMPOfflineContentManager Protocol Reference