use of org.prebid.mobile.VideoInterstitialAdUnit in project prebid-mobile-android by prebid.
the class RubiconInterstitialVideoGamDemoActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
PrebidMobile.setPrebidServerHost(Host.RUBICON);
PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_RUBICON);
PrebidMobile.setStoredAuctionResponse(Constants.PBS_STORED_RESPONSE_VAST_RUBICON);
VideoBaseAdUnit.Parameters parameters = new VideoBaseAdUnit.Parameters();
parameters.setMimes(Arrays.asList("video/mp4"));
parameters.setProtocols(Arrays.asList(Signals.Protocols.VAST_2_0));
// parameters.setProtocols(Arrays.asList(new Signals.Protocols(2)));
parameters.setPlaybackMethod(Arrays.asList(Signals.PlaybackMethod.AutoPlaySoundOff));
// parameters.setPlaybackMethod(Arrays.asList(new Signals.PlaybackMethod(2)));
VideoInterstitialAdUnit adUnit = new VideoInterstitialAdUnit("1001-1");
adUnit.setParameters(parameters);
this.adUnit = adUnit;
int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
adUnit.setAutoRefreshPeriodMillis(millis);
final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
adUnit.fetchDemand(builder, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
AdManagerAdRequest request = builder.build();
AdManagerInterstitialAd.load(RubiconInterstitialVideoGamDemoActivity.this, Constants.DFP_VAST_ADUNIT_ID_RUBICON, request, new AdManagerInterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull AdManagerInterstitialAd adManagerInterstitialAd) {
super.onAdLoaded(adManagerInterstitialAd);
adManagerInterstitialAd.show(RubiconInterstitialVideoGamDemoActivity.this);
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(RubiconInterstitialVideoGamDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(RubiconInterstitialVideoGamDemoActivity.this);
}
builder.setTitle("Failed to load AdManager interstitial ad").setMessage("Error: " + loadAdError.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
}
});
}
});
}
use of org.prebid.mobile.VideoInterstitialAdUnit in project prebid-mobile-android by prebid.
the class RubiconInterstitialVideoMoPubDemoActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
PrebidMobile.setPrebidServerHost(Host.RUBICON);
PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_RUBICON);
PrebidMobile.setStoredAuctionResponse(Constants.PBS_STORED_RESPONSE_VAST_RUBICON);
VideoBaseAdUnit.Parameters parameters = new VideoBaseAdUnit.Parameters();
parameters.setMimes(Arrays.asList("video/mp4"));
parameters.setProtocols(Arrays.asList(Signals.Protocols.VAST_2_0));
// parameters.setProtocols(Arrays.asList(new Signals.Protocols(2)));
parameters.setPlaybackMethod(Arrays.asList(Signals.PlaybackMethod.AutoPlaySoundOff));
// parameters.setPlaybackMethod(Arrays.asList(new Signals.PlaybackMethod(2)));
VideoInterstitialAdUnit adUnit = new VideoInterstitialAdUnit("1001-1");
adUnit.setParameters(parameters);
this.adUnit = adUnit;
final MoPubInterstitial mpInterstitial = new MoPubInterstitial(this, Constants.MOPUB_INTERSTITIAL_VIDEO_ADUNIT_ID_RUBICON);
mpInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener() {
@Override
public void onInterstitialLoaded(MoPubInterstitial interstitial) {
interstitial.show();
}
@Override
public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(RubiconInterstitialVideoMoPubDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(RubiconInterstitialVideoMoPubDemoActivity.this);
}
builder.setTitle("Failed to load MoPub interstitial ad").setMessage("Error code: " + errorCode.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
}
@Override
public void onInterstitialShown(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialClicked(MoPubInterstitial interstitial) {
}
@Override
public void onInterstitialDismissed(MoPubInterstitial interstitial) {
}
});
int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
adUnit.setAutoRefreshPeriodMillis(millis);
adUnit.fetchDemand(mpInterstitial, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
mpInterstitial.load();
}
});
}
Aggregations