VideoAdUnit: AdUnit

The VideoAdUnit is a subclass of the AdUnit class. Use the VideoAdUnit object to create and configure a video outstream ad unit in your app.

Video Outstream is only supported with Google Ad Manager.

Object

VideoAdUnit

Create a new Video Outstream Ad Unit associated with a Prebid Server configuration ID and a video size.

See AdUnit for additional parameters and methods.

VideoAdUnit(configId: String, size: CGSize(width: Int, height: Int), type:Enum)

Parameters

configId(String): Prebid Server configuration ID.

size(CGSize): Width and height of the video ad unit.

type:Enum: OpenRTB Placement Type.

CGSize

Size of video ad unit.

Parameters

width: Width of video ad unit in DIPs.

height: Height of video ad unit in DIPs.

type

OpenRTB Placement Type represented as an enumeration of values:

  • inBanner is transformed into OpenRTB value 2 to bid adapters
  • inArticle is transformed into OpenRTB value 3 to bid adapters
  • inFeed is transformed into OpenRTB value 4 to bid adapters

See AdUnit for additional parameters and methods.


Example

Google Mobile Ads

Import the GoogleMobileAds from google-mobile-sdk into the UIViewController displaying the VideoAdUnit.

Swift

    var amBanner: DFPBannerView!
    var adUnit: AdUnit!

    func setupAndLoadAMBannerVAST() {

        setupPBBannerVAST()

        setupAMBannerVAST()

        loadBanner()
    }

    func setupPBBannerVAST() {

        Prebid.shared.prebidServerHost = .Rubicon
        Prebid.shared.prebidServerAccountId = "accountId"

        adUnit = VideoAdUnit(configId: "configId", size: CGSize(width: 300, height: 250), type: .inBanner)
    }

    func setupAMBannerVAST() {
        setupAMBanner(id: "/5300653/test_adunit_vast_pavliuchyk")
    }

    func setupAMBanner(id: String) {
        amBanner = DFPBannerView(adSize: kGADAdSizeMediumRectangle)
        amBanner.adUnitID = id
    }

    func loadBanner() {

        adUnit.fetchDemand(adObject: self.request) { [weak self] (resultCode: ResultCode) in
            print("Prebid demand fetch for DFP \(resultCode.name())")
        }
    }