DTGContentManager
public protocol DTGContentManager : AnyObject
Main entry point of the library, used to control item download and get their playback URL.
-
The storage path for directories and files.
Declaration
Swift
var storagePath: URL { get }
-
Delegate that will receive download events.
Declaration
Swift
var delegate: ContentManagerDelegate? { get set }
-
setLogLevel(_:)
Default implementationset log level for viewing logs.
Default Implementation
Declaration
Swift
func setLogLevel(_ logLevel: LogLevel)
-
Start the content manager. This also starts the playback server.
Declaration
Swift
func start(completionHandler: (() -> Void)?) throws
-
Stop the content manager, including the playback server.
Declaration
Swift
func stop()
-
Return all items in the specified state.
Declaration
Swift
func itemsByState(_ state: DTGItemState) throws -> [DTGItem]
-
Find an existing item.
Declaration
Swift
func itemById(_ id: String) throws -> DTGItem?
Parameters
id
the item’s unique id.
Return Value
an item, or nil if not found.
-
Add a new item.
Declaration
Swift
func addItem(id: String, url: URL) throws -> DTGItem?
Parameters
id
a unique id for the new item
url
the remote URL of the item.
Return Value
the newly allocated item or nil if already exists.
-
Load metadata for the given item id.
Attention
This method executes on the thread it is called and takes time to finish, the best practice is to call this method from a background queue.Throws
DTGError.itemNotFoundDeclaration
Swift
func loadItemMetadata(id: String, preferredVideoBitrate: Int?) throws
Parameters
id
the item’s unique id.
callback
block that takes the updated item.
-
Start or resume item download.
Throws
DTGError.itemNotFoundDeclaration
Swift
func startItem(id: String) throws
-
Start items download in specified states. can be used to resume inProgress (after force quit) / interrupted / paused items, can use multiple selection or just one.
try startItems(inStates: .inProgress) // or like this: try startItems(inStates: .inProgress, .paused)
Declaration
Swift
func startItems(inStates states: DTGItemStartableState...) throws
Parameters
states
The states to start.
-
Pause downloading an item.
Throws
DTGError.itemNotFoundDeclaration
Swift
func pauseItem(id: String) throws
-
Remove an existing item from storage, deleting all related files.
Throws
DTGError.itemNotFoundDeclaration
Swift
func removeItem(id: String) throws
-
Get a playable URL for an item.
Throws
DTGError.itemNotFoundDeclaration
Swift
func itemPlaybackUrl(id: String) throws -> URL?
Return Value
a playback URL, or nil.
-
Handles events of a background session waiting to be processed.
Declaration
Swift
func handleEventsForBackgroundURLSession(identifier: String, completionHandler: @escaping () -> Void)
Parameters
identifier
The background url session identifier.
completionHandler
the completionHandler to call when finished handling the events.
-
handles all the setup needed by the content manager, must be called on AppDelegate in:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
Declaration
Swift
func setup() throws
-
Set the default audio bitrate for size-estimation purposes. Defaults to 64000.
Declaration
Swift
func setDefaultAudioBitrateEstimation(bitrate: Int)