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 the APIConfig and AuthManager provided are correctly configured to avoid issues during API requests and authentication. Use vesperSDKManager to create PlayerManager
  • Initializes a new instance of VesperSDKManager with 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 APIConfig and AuthManager instances are properly configured before initializing the VesperSDKManager to avoid potential runtime errors.

    Declaration

    Swift

    public init(config: VesperSDKConfig)

    Parameters

    config

    An instance of VesperSDKConfig that 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

    completion

    A closure that is called with a Result containing either a RealmSettings instance on success or an Error on failure.

  • Creates and configures a PlayerManager instance.

    This method initializes a new PlayerManager with the provided player, configuration, output delegate, and UI type. Upon completion, it returns the result containing either the successfully created PlayerManager or an Error if something went wrong.

    Note

    The uiType parameter 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

    player

    The AVPlayer instance to be managed. Defaults to a new AVPlayer instance.

    playerConfig

    The configuration settings for the player. Defaults to .default.

    playerOutput

    An optional output delegate conforming to DorisPlayerOutputProtocol for handling player events. Defaults to nil.

    userInterfaceConfig

    The type of UI to be associated with the player.

    completion

    A closure that is called with a Result containing either a PlayerManager instance on success or an Error on 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

    isDebug

    true to enable debug logs, false to disable them.