VesperSDKManager
public class VesperSDKManager
The VesperSDKManager class serves as the central manager for handling API requests, authentication,
and resolving application settings within the Vesper SDK. Also it allow to create PlayerManager to manager playback
This class encapsulates and coordinates various components, including API configuration, request management, authentication, and settings resolution.
Important
Ensure that theAPIConfig and AuthManager provided are correctly configured to avoid issues
during API requests and authentication.
Use vesperSDKManager to create PlayerManager
-
Initializes a new instance of
VesperSDKManagerwith the provided API configuration and authentication manager.This initializer sets up the core components of the
VesperSDKManager, including the request manager, authentication manager, and settings resolver.Important
Ensure that both the
APIConfigandAuthManagerinstances are properly configured before initializing theVesperSDKManagerto avoid potential runtime errors.Declaration
Swift
public init(config: VesperSDKConfig)Parameters
configAn instance of
VesperSDKConfigthat provides the configuration settings -
Resolves application settings from the Vesper API.
This method fetches and resolves the application settings required for the SDK to function properly. The settings include configuration for ads, UI styling, tracks policy, and other application-specific settings. If multiple calls are made while a request is in progress, all callers will receive the same result when the request completes.
Note
The settings are cached after the first successful resolution. Subsequent calls will return the cached settings immediately. If the API request fails, the method will attempt to use cached settings from UserDefaults if available.
Example:
vesperSDKManager.resolveSettings { result in switch result { case .success(let settings): // Use the settings print("Mux Key: \(settings.muxKey)") case .failure(let error): // Handle the error print("Failed to resolve settings: \(error)") } }
Declaration
Swift
public func resolveSettings(completion: @escaping (Result<RealmSettings, Error>) -> Void)Parameters
completionA closure that is called with a
Resultcontaining either aRealmSettingsinstance on success or anErroron failure. -
Creates and configures a
PlayerManagerinstance.This method initializes a new
PlayerManagerwith the provided player, configuration, output delegate, and UI type. Upon completion, it returns the result containing either the successfully createdPlayerManageror anErrorif something went wrong.Note
The
uiTypeparameter is required to define the UI representation of the player, which might influence how the player interacts with the user.Example:
createPlayerManager(userInterfaceConfig: .default(output: nil)) { result in switch result { case .success(let playerManager): // Use the playerManager case .failure(let error): // Handle the error } }
Declaration
Swift
public func createPlayerManager(player: AVPlayer = AVPlayer(), playerConfig: PlayerConfig = .default, playerOutput: DorisPlayerOutputProtocol? = nil, userInterfaceConfig: UserInterfaceConfig, completion: @escaping (Result<PlayerManager, Error>) -> Void)Parameters
playerThe
AVPlayerinstance to be managed. Defaults to a newAVPlayerinstance.playerConfigThe configuration settings for the player. Defaults to
.default.playerOutputAn optional output delegate conforming to
DorisPlayerOutputProtocolfor handling player events. Defaults tonil.userInterfaceConfigThe type of UI to be associated with the player.
completionA closure that is called with a
Resultcontaining either aPlayerManagerinstance on success or anErroron failure.Return Value
This method does not return a value directly. Instead, it uses the completion closure to provide the result asynchronously.
-
Enables or disables SDK debug logging.
When enabled, this turns on verbose HTTP logs, PlayerManager logs, UIManager logs
Declaration
Swift
public static func setDebugEnabled(_ isDebugEnabled: Bool)Parameters
isDebugtrueto enable debug logs,falseto disable them.