VideoAdUnit Object

Use the VideoAdUnit object to create and configure an outstream video ad unit in your app.

Video Outstream is only supported with Google Ad Manager.

Object

VideoAdUnit

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

VideoAdUnit("configID", width, height, VideoAdUnit.PlacementType.placement);

Parameters

  • configId: String; Prebid Server configuration ID.
  • width: Integer; Width of the video player.
  • height: Integer; Height of the video player.
  • placement Enumeration. Possible values:
    • IN_BANNER
    • IN_ARTICLE
    • IN_FEED

Methods

VideoAdUnit inherits all methods from the AdUnit object.

Example

private PublisherAdView amBanner;
AdUnit adUnit;

void setupAndLoadAMBannerVAST() {
   setupPBBannerVAST();
   setupAMBannerVAST();
   loadBanner();
}

private void setupPBBannerVAST() {
   PrebidMobile.setPrebidServerHost(Host.RUBICON);
   PrebidMobile.setPrebidServerAccountId("AccountID");
   adUnit = new VideoAdUnit("configId", 300, 250, VideoAdUnit.PlacementType.IN_BANNER);
}

private void setupAMBannerVAST() {
   setupAMBanner(300, 250, "/networkId/adUnit");
}

private void setupAMBanner(int width, int height, String id) {
   amBanner = new PublisherAdView(this);
   amBanner.setAdUnitId(id);
   amBanner.setAdSizes(new AdSize(width, height));
}

private void loadBanner() {
   final PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
   final PublisherAdRequest request = builder.build();
   adUnit.fetchDemand(request, new OnCompleteListener() {
       @Override
       public void onComplete(ResultCode resultCode) {
           DemoActivity.this.resultCode = resultCode;
       }
   });
}