Use the VideoAdUnit
object to create and configure an outstream video 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.
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:
VideoAdUnit
inherits all methods from the AdUnit object.
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;
}
});
}