Search in sources :

Example 1 with RewardedVideoAdUnit

use of org.prebid.mobile.RewardedVideoAdUnit in project prebid-mobile-android by prebid.

the class RubiconRewardedVideoMoPubDemoActivity 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)));
    RewardedVideoAdUnit adUnit = new RewardedVideoAdUnit("1001-1");
    adUnit.setParameters(parameters);
    this.adUnit = adUnit;
    SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(Constants.MP_ADUNITID_REWARDED).build();
    MoPub.initializeSdk(this, sdkConfiguration, null);
    MoPubRewardedVideos.setRewardedVideoListener(this);
    final Map<String, String> keywordsMap = new HashMap<>();
    adUnit.fetchDemand(keywordsMap, new OnCompleteListener() {

        @Override
        public void onComplete(ResultCode resultCode) {
            MoPubRewardedVideoManager.RequestParameters parameters = new MoPubRewardedVideoManager.RequestParameters(Util.convertMapToMoPubKeywords(keywordsMap));
            MoPubRewardedVideos.loadRewardedVideo(Constants.MP_ADUNITID_REWARDED, parameters, (MediationSettings) null);
        }
    });
}
Also used : HashMap(java.util.HashMap) RewardedVideoAdUnit(org.prebid.mobile.RewardedVideoAdUnit) OnCompleteListener(org.prebid.mobile.OnCompleteListener) VideoBaseAdUnit(org.prebid.mobile.VideoBaseAdUnit) SdkConfiguration(com.mopub.common.SdkConfiguration) MediationSettings(com.mopub.common.MediationSettings) ResultCode(org.prebid.mobile.ResultCode) MoPubRewardedVideoManager(com.mopub.mobileads.MoPubRewardedVideoManager)

Example 2 with RewardedVideoAdUnit

use of org.prebid.mobile.RewardedVideoAdUnit in project prebid-mobile-android by prebid.

the class RubiconRewardedVideoGamDemoActivity 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)));
    RewardedVideoAdUnit adUnit = new RewardedVideoAdUnit("1001-1");
    adUnit.setParameters(parameters);
    this.adUnit = adUnit;
    final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
    adUnit.fetchDemand(builder, new OnCompleteListener() {

        @Override
        public void onComplete(ResultCode resultCode) {
            AdManagerAdRequest request = builder.build();
            RewardedAd.load(RubiconRewardedVideoGamDemoActivity.this, Constants.DFP_REWARDED_ADUNIT_ID_RUBICON, request, new RewardedAdLoadCallback() {

                @Override
                public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
                    super.onAdLoaded(rewardedAd);
                    rewardedAd.show(RubiconRewardedVideoGamDemoActivity.this, new OnUserEarnedRewardListener() {

                        @Override
                        public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
                        }
                    });
                }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
                    super.onAdFailedToLoad(loadAdError);
                }
            });
        }
    });
}
Also used : LoadAdError(com.google.android.gms.ads.LoadAdError) OnUserEarnedRewardListener(com.google.android.gms.ads.OnUserEarnedRewardListener) RewardedAdLoadCallback(com.google.android.gms.ads.rewarded.RewardedAdLoadCallback) RewardedVideoAdUnit(org.prebid.mobile.RewardedVideoAdUnit) OnCompleteListener(org.prebid.mobile.OnCompleteListener) RewardedAd(com.google.android.gms.ads.rewarded.RewardedAd) NonNull(androidx.annotation.NonNull) RewardItem(com.google.android.gms.ads.rewarded.RewardItem) VideoBaseAdUnit(org.prebid.mobile.VideoBaseAdUnit) AdManagerAdRequest(com.google.android.gms.ads.admanager.AdManagerAdRequest) ResultCode(org.prebid.mobile.ResultCode)

Aggregations

OnCompleteListener (org.prebid.mobile.OnCompleteListener)2 ResultCode (org.prebid.mobile.ResultCode)2 RewardedVideoAdUnit (org.prebid.mobile.RewardedVideoAdUnit)2 VideoBaseAdUnit (org.prebid.mobile.VideoBaseAdUnit)2 NonNull (androidx.annotation.NonNull)1 LoadAdError (com.google.android.gms.ads.LoadAdError)1 OnUserEarnedRewardListener (com.google.android.gms.ads.OnUserEarnedRewardListener)1 AdManagerAdRequest (com.google.android.gms.ads.admanager.AdManagerAdRequest)1 RewardItem (com.google.android.gms.ads.rewarded.RewardItem)1 RewardedAd (com.google.android.gms.ads.rewarded.RewardedAd)1 RewardedAdLoadCallback (com.google.android.gms.ads.rewarded.RewardedAdLoadCallback)1 MediationSettings (com.mopub.common.MediationSettings)1 SdkConfiguration (com.mopub.common.SdkConfiguration)1 MoPubRewardedVideoManager (com.mopub.mobileads.MoPubRewardedVideoManager)1 HashMap (java.util.HashMap)1