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.

Currently Google Ad Manager is the only supported ad server. We plan to provide support for additional ad servers in subsequent releases.

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

videoAd: Video Events

videoAd

  • Video event listeners

videoAd (event: PBVideoAdEvent): Event to listen to.

Parameters

Events - one of the below event types:

  • AdLoadSuccess
  • AdLoadFail
  • AdClicked
  • AdStarted
  • AdDidReachEnd

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())")
        }
    }