OTVPersistenceManager
final public class 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
Swift
@objc public static let shared: OTVPersistenceManager -
Start a media stream dowloading.
Note
You MUST NOT share the same license delegate instance for multiple downloading.Declaration
Swift
@objc(startDownloadWithUrlAsset:title:licenseDelegate:artwork:options:) public func startDownload(urlAsset: AVURLAsset, title: String, licenseDelegate: OTVLicenseDelegate?, artwork: Data?, options: [String : Any]? = nil) -> OTVPersistenceAsset?Parameters
urlAssetAsset needs to be downloaded
titleStream’s title
licenseDelegateDelegate to fetch the license
artworkartwork Data
optionsdownload options
Return Value
an asset created for this download.
-
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
Declaration
Swift
@objc(prepareDownloadWithUrl:title:) public func prepareDownload(url: URL, title: String) -> OTVPersistenceAssetParameters
urlUrl of asset needs to be downloaded
titleStream’s title
Return Value
an asset created for this download.
-
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
Declaration
Swift
@objc(startDownloadWithAsset:artwork:options:avMediaSelectionOptions:) public func startDownload(asset: OTVPersistenceAsset, artwork: Data?, options: [String : Any]? = nil, avMediaSelectionOptions: [AVMediaSelection]? = nil) -> BoolParameters
assetan object of
OTVPersistenceAssetinpreparedstateartworkartwork Data
optionsdownload options
avMediaSelectionOptionsthe media selection to download, if it is not set, the default selection will be download
Return Value
Trueif download start successful,Falseif there is some error, e.g. theassetis not inpreparedstate. - 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
Declaration
Swift
@objc(startDownloadWithAsset:artwork:options:) public func startDownload(asset: OTVPersistenceAsset, artwork: Data?, options: [String : Any]? = nil) -> BoolParameters
assetan object of
OTVPersistenceAssetinpreparedstateartworkartwork Data
optionsdownload options
Return Value
Trueif download start successful,Falseif there is some error, e.g. theassetis not inpreparedstate. - You MUST call
-
Return downloading and downloaded assets.
Declaration
Swift
@objc public func getDownloads() -> [OTVPersistenceAsset]? -
Pause the downloading of assigned asset.
Declaration
Swift
@objc public func pauseDownload(asset: OTVPersistenceAsset) -> BoolParameters
assetthe asset to be paused.
-
Resume the paused downloading asset.
Declaration
Swift
@objc public func resumeDownload(asset: OTVPersistenceAsset) -> BoolParameters
assetthe asset to be resumed.
-
Cancel or remove the asset.
Declaration
Swift
@objc public func deleteDownload(asset: OTVPersistenceAsset) -> BoolParameters
assetthe asset to be cancelled or removed.
-
Extends
See moreOTVPersistenceManagerto define a number of values to use as keys in dictionary options.Declaration
Swift
public struct Keys -
Declaration
Swift
@objc public func totalDiskSpaceInBytes() -> Int64 -
Declaration
Swift
@objc public func freeDiskSpaceInBytes() -> Int64 -
Declaration
Swift
@objc public func usedDiskSpaceInBytes() -> Int64