This document outlines the steps to integrate the Primis Video Player into your Android mobile application using AppLovin MAX as the primary mediation layer. By following this guide, you will be able to serve the Primis player within a standard 300x250 MREC placement and utilize Primis video demand for your apps.
Prerequisites
Before beginning the integration, ensure you have the following:
- You have received ApplovinMax SDK Integration Guide and ad units details from your Freestar Team.
- You have Google Ad Manager and ApplovinMax GAM adapters installed using cocoapods.
- The AppLovin MAX SDK has been successfully integrated into your Android or iOS project.
Implementation (Code Level)
The Primis player will be treated as a standard MREC view. Below are the implementation snippets for basic initialization and loading Primis player in ad view.
public class ExampleActivity extends Activity
implements MaxAdViewAdListener
{
private MaxAdView adView;
void createMRecAd()
{
adView = new MaxAdView( "«ad-unit-ID»", MaxAdFormat.MREC, this );
adView.setListener( this );
// MREC width and height are 300 and 250 respectively, on phones and tablets
int widthPx = AppLovinSdkUtils.dpToPx( this, 300 );
int heightPx = AppLovinSdkUtils.dpToPx( this, 250 );
adView.setLayoutParams( new FrameLayout.LayoutParams( widthPx, heightPx ) );
// Set background color for MRECs to be fully functional
adView.setBackgroundColor( «background-color» );
ViewGroup rootView = findViewById( android.R.id.content );
rootView.addView( adView );
// Load the ad
adView.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd) {}
@Override
public void onAdLoadFailed(final String adUnitId, final MaxError error) {}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdExpanded(final MaxAd maxAd) {}
@Override
public void onAdCollapsed(final MaxAd maxAd) {}
@Override
public void onAdDisplayed(final MaxAd maxAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
@Override
public void onAdHidden(final MaxAd maxAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}
Loading and showing an MREC in Layout Editor
You can also add MAXMRE Cs to your view layout XML.
Ensure that your ads are fully functional by setting a background or background color (android:background). For MRECs, set android:adFormat accordingly (as shown in bold line below).
<com.applovin.mediation.ads.MaxAdView
xmlns:maxads="http://schemas.applovin.com/android/1.0"
maxads:adUnitId="«ad-unit-ID»"
maxads:adFormat="MREC"
android:background="@color/mrec_background_color"
android:layout_width="300dp"
android:layout_height="250dp" />
You still must call loadAd() on the MaxAdView you create in this way:
MaxAdView adView = findViewById( R.id.ad_view );
adView.loadAd();
Destroying MREC Ads
If you no longer need a MaxAdView instance, call its destroy() method to free resources. This may be the case, for example, if the user purchases ad removal. Do not call the destroy() method if you use multiple instances with the same Ad Unit ID.
adView.destroy();Stopping auto-refresh
The MREC ad unit being set up for Primis should not refresh automatically.
adView.setExtraParameter( "allow_pause_auto_refresh_immediately", "true" );
adView.stopAutoRefresh();Manually refresh the contents with the following call. You must stop auto-refresh before you call loadAd().
adView.loadAd();
Please reach out to your Freestar Team to test the Primis ad unit with test ads once you have completed the integration.