OTVPersistenceManager
@interface OTVPersistenceManager : NSObject
OTVPersistenceManager is a singleton that manages all download related functionality.
It utilises OTVDownloadingAssetManager for outstanding downloads and OTVAssetsManager for completed downloads.
-
Persistence Manager singleton instance.
Declaration
Objective-C
@property (class, nonatomic, strong, readonly) OTVPersistenceManager *_Nonnull shared; -
Start a media stream dowloading. note: You MUST NOT share the same license delegate instance for multiple downloading. \param urlAsset Asset needs to be downloaded
\param title Stream’s title
\param licenseDelegate Delegate to fetch the license
\param artwork artwork Data
\param options download options
returns: an asset created for this download.
Declaration
Objective-C
- (OTVPersistenceAsset *_Nullable) startDownloadWithUrlAsset:(AVURLAsset *_Nonnull)urlAsset title:(NSString *_Nonnull)title licenseDelegate:(id<OTVLicenseDelegate> _Nullable)licenseDelegate artwork:(NSData *_Nullable)artwork options:(NSDictionary<NSString *, id> *_Nullable)options; -
Start Preparing a media stream ready for dowloading. note:
- To begin the download you must wait for the prepared download state on the OTVPersistenceAsset returned here.
-
Once the OTVPersistenceAsset has entered
preparedstate:- You can check the mediaInfo values on the OTVPersistenceAsset
-
You can query the
OTVPersistenceAsset.mediaInfo.availableStreamInfoto see all the information needed to start downloading the asset. -
You can query the
OTVPersistenceAsset.mediaInfo.availableDrmInfoto get the drm information of the asset.
- You SHOULD retain the object returned from preparedDownload, and pass the object to call startDownload: persistenceAsset… when state is changed to Prepared
\param url Url of asset needs to be downloaded
\param title Stream’s title
returns: an asset created for this download.
Declaration
Objective-C
- (OTVPersistenceAsset *_Nonnull)prepareDownloadWithUrl:(NSURL *_Nonnull)url title: (NSString *_Nonnull)title; -
Start a media stream dowloading for a
OTVPersistenceAssetnote:-
You MUST call
prepareDownloadand wait for statePreparedon theOTVPersistenceAssetbefore calling this function-
If the stream is FPS encrypted, you MUST call
setupFPS:on the preparedOTVPersistenceAssetbefore calling this function, and pass anOTVLicenseDelegateinstance; -
If the stream is PRM encrypted, you MUST call
setupPRM:on the preparedOTVPersistenceAssetbefore call this function, and pass anOTVPRMAVURLAssetobject; -
If the stream is clear one, you SHOULD NOT call
setupFPS:orsetupPRM:on the preparedOTVPersistenceAsset. -
You can set a number of values on the
OTVPersistenceAssetto choose what resolution and bitrate you want to download -
You can do this by setting
OTVPersistenceAsset.mediaInfo.selectedStreamInfofrom selection one of theOTVPersistenceAsset.mediaInfo.availableStreamInfo -
If no value is set for
OTVPersistenceAsset.mediaInfo.selectedStreamInfowe will check theoptionsvalue passed into this function. - If neither of these values are set then we will use the highest possible value you are able to download.
-
If the stream is FPS encrypted, you MUST call
\param asset an object of
OTVPersistenceAssetinpreparedstate\param artwork artwork Data
\param options download options
\param avMediaSelectionOptions the media selection to download, if it is not set, the default selection will be download
returns:
Trueif download start successful,Falseif there is some error, e.g. theassetis not inpreparedstate.Declaration
Objective-C
- (BOOL)startDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset artwork:(NSData *_Nullable)artwork options:(NSDictionary<NSString *, id> *_Nullable)options avMediaSelectionOptions: (NSArray<AVMediaSelection *> *_Nullable)avMediaSelectionOptions; -
You MUST call
-
Start a media stream dowloading for a
OTVPersistenceAssetnote:-
You MUST call
prepareDownloadand wait for statePreparedon theOTVPersistenceAssetbefore calling this function-
If the stream is FPS encrypted, you MUST call
setupFPS:on the preparedOTVPersistenceAssetbefore calling this function, and pass anOTVLicenseDelegateinstance; -
If the stream is PRM encrypted, you MUST call
setupPRM:on the preparedOTVPersistenceAssetbefore call this function, and pass anOTVPRMAVURLAssetobject; -
If the stream is clear one, you SHOULD NOT call
setupFPS:orsetupPRM:on the preparedOTVPersistenceAsset. -
You can set a number of values on the
OTVPersistenceAssetto choose what resolution and bitrate you want to download -
You can do this by setting
OTVPersistenceAsset.mediaInfo.selectedStreamInfofrom selection one of theOTVPersistenceAsset.mediaInfo.availableStreamInfo -
If no value is set for
OTVPersistenceAsset.mediaInfo.selectedStreamInfowe will check theoptionsvalue passed into this function. - If neither of these values are set then we will use the highest possible value you are able to download.
-
If the stream is FPS encrypted, you MUST call
\param asset an object of
OTVPersistenceAssetinpreparedstate\param artwork artwork Data
\param options download options
returns:
Trueif download start successful,Falseif there is some error, e.g. theassetis not inpreparedstate.Declaration
Objective-C
- (BOOL)startDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset artwork:(NSData *_Nullable)artwork options:(NSDictionary<NSString *, id> *_Nullable)options; -
You MUST call
-
Return downloading and downloaded assets.
Declaration
Objective-C
- (NSArray<OTVPersistenceAsset *> *_Nullable)getDownloads; -
Pause the downloading of assigned asset. \param asset the asset to be paused.
Declaration
Objective-C
- (BOOL)pauseDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset; -
Resume the paused downloading asset. \param asset the asset to be resumed.
Declaration
Objective-C
- (BOOL)resumeDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset; -
Cancel or remove the asset. \param asset the asset to be cancelled or removed.
Declaration
Objective-C
- (BOOL)deleteDownloadWithAsset:(OTVPersistenceAsset *_Nonnull)asset;