PlayerBuilder settings

PlayerBuilder is used to determine custom settings of your choice to the player and initialize it with it.

  • Init requires a UIViewController and a UIView.
public init(parentVC: UIViewController, playerView: UIView)
  • PlayerBuilder settings:
  • Init your PlayerBuilder with selected settings and assign your viewController and view to it.
  • Run PlayerBuilder method .build() to initialize your player.
  • After the view appears, in viewDidAppear() or on a button action call TargetVideoPlayer method .loadVideo to show player with selected video, or .loadPlaylist to show your playlist.
public class PlayerBuilder {
  
    public init(parentVC: UIViewController, playerView: UIView)

    public func setMuteOnStart(_ isMuted: Bool)

    /// Sets the autoplay behavior for the player.
    ///
    /// - Parameter controlAutoplay: If `true`, video will not autoplay and the user will receive a `.videoAutoplay` notification
    ///                         and can handle autoplay themselves.
    public func controlAutoplay(_ controlAutoplay: Bool)

    public func setPlayerReference(_ playerReference: String)

    /// Sets the language for the player base on country code.
    ///
    /// - Parameter contryCode: Available languages: ["en", "es", "de", "fr", "it", "ru", "pt", "sr", "me", "hr", "bs", "sl"]
    ///
    public func setPlayerLanguage(countryCode: String)

    public func setControllerTimeoutMs(_ timeoutMS: Int)

    /// Sets custom ad macros to a Ad Tag URL.
    ///
    /// - Parameter macros: dictionary that takes macro id key and value. example: ["[page_url]":  "https://example.com"].
    ///
    public func setAdMacros(_ adMacros: [String : String])

    /// Builds and returns a configured `TargetVideoPlayer` instance.
    ///
    /// This method creates a `BuilderSettingsModel` using the provided settings such as mute state, autoplay control, seek seconds,
    /// player reference, country code, timeout, and ad macros. The `TargetVideoPlayer` is then initialized with the parent view controller,
    /// the player view, and the constructed `BuilderSettingsModel`.
    ///
    /// - Returns: A fully configured `TargetVideoPlayer` instance.
    public func build() -> TargetVideoSDKtvOS.TargetVideoPlayer
}