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
SourceConfig
which is managed by thisOfflineContentManager
instance.Declaration
Objective-C
@property (nonatomic, strong, readonly) BMPSourceConfig *_Nonnull sourceConfig;
Swift
var sourceConfig: BMPSourceConfig { get }
-
The current offline state for the
SourceConfig
which 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.prepareSyncMessage
andFairplayConfig.prepareOfflineDrmLicenseInformation
are 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
DrmLicenseInformation
representing 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
OfflineContentManagerTweaksApi
for interactions regarding the tweaks.Declaration
Objective-C
@property (nonatomic, readonly) id<BMPOfflineContentManagerTweaksApi> _Nonnull tweaks;
Swift
var tweaks: any BMPOfflineContentManagerTweaksApi { get }
-
Creates and returns a
OfflineSourceConfig
which should be used with aPlayer
instance when playback of offline content is desired.When intending to create an
OfflineSourceConfig
for DRM protected content, the accordingDrmConfig
needs to be applied to the passed sourceConfig before creating theOfflineSourceConfig
.Note
ThumbnailTrack
s are not respected by this flag.Declaration
Objective-C
- (nullable BMPOfflineSourceConfig *)createOfflineSourceConfig: (BOOL)restrictedToAssetCache;
Swift
func createOfflineSourceConfig(restrictedToAssetCache: Bool) -> BMPOfflineSourceConfig?
Parameters
restrictedToAssetCache
Whether 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
true
if the device has no network access.Return Value
OfflineSourceConfig
which can be used with aPlayer
instance for offline playback, ornil
if 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
OfflineState
isOfflineStateNotDownloaded
. 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
OfflineState
isOfflineStateNotDownloaded
. 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
downloadConfig
The
DownloadConfig
used for this download. -
Downloads the media data associated with the managed
SourceConfig
.Calling this method is only valid when the
OfflineState
isOfflineStateNotDownloaded
. 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
downloadConfig
The
DownloadConfig
used for this download.tracks
The
OfflineTrackSelection
with the desired tracks -
Cancels all running download tasks associated with the managed
SourceConfig
and deletes the partially downloaded content from disk.Calling this method is only valid when the
offlineState
isOfflineStateDownloading
orOfflineStateSuspended
. 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
offlineState
isOfflineStateDownloading
. 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
offlineState
isOfflineStateSuspended
. 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
offlineState
isOfflineStateDownloaded
. 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.prepareOfflineDrmLicenseInformation
block is called after the KSM was queried successfully.Declaration
Objective-C
- (void)syncOfflineDrmLicenseInformation;
Swift
func syncOfflineDrmLicenseInformation()