Exoplayer SDK with Nowtilus SSAI JIO

This document explains the process to integrate MM SDK with Google Exoplayer version v2.12.2 and v2.11.8

STEP 1 :

Each SDK release directory contain the class files required for building a jar which is used in the application . The jar can be created as follows

jar cvf <name_of_the_jar>.jar .

STEP 2: Add the .jar file as a dependency in the Exoplayer build.gradle file.

api files ('name_of_the_jar.jar')

STEP 3: Add the below lines to the Exoplayer PlayerActivity.java.

import com.mediamelon.smartstreaming.MMQBRMode;
import com.mediamelon.smartstreaming.MMSmartStreaming;
import com.mediamelon.smartstreaming.MMSmartStreamingExo2;
import com.mediamelon.smartstreaming.MMSmartStreamingInitializationStatus;
import com.mediamelon.smartstreaming.MMSmartStreamingObserver;
import com.mediamelon.qubit.PropertyReader;

STEP 4 :Add the below lines in onCreate method of PlayerActivity.java.

MMSmartStreamingExo2.getInstance().setContext(getApplicationContext()); //Please make sure to provide the application's context 

STEP 5: Get the mediaURL and vastURL from the Nowtilus SSAI stream url.

NOTE - The player needs to be given the extracted mediaURL as the playback URL.

String streamURL = "NOWTILUS SSAI URL";
/*
The streamURL gives the mediaURL and VastURL as a response as shown below ,extract the mediaURL and vastURL from the response
*/
{"mediaURL":"https://ssaipre.serverside.ai/hls/f18e5f62-230a-4cad-baf7-3d0e6d429aa7/master.m3u8?sid=75291960-6256-11ec-823d-5bdd72099bb9&api-key=31c8e40a-ee55-4a49-8af2-c76375b22b6e","vastURL":"https://ssaipre.serverside.ai/hls/f18e5f62-230a-4cad-baf7-3d0e6d429aa7/75291960-6256-11ec-823d-5bdd72099bb9/vast.xml"}

STEP 6: Add the below lines to the initializePlayer() method. Add the lines after the player is initialized and not null.

NOTE - boolean enablePollingforSSAI variable indicates whether the Mediamelon SDK needs to poll for the VAST URL or not. Please set it to true if you want to opt for polling else set it to false.And set isLive parameter to true for live streams and false for VOD.

private void initializePlayer() {
...
...
...
...
MMSmartStreamingExo2.getInstance().setPlayer(player);
MMSmartStreamingExo2.getInstance().vastURLfromApplication ="extracted vastURL from the NOwtilus SSAI URL";
boolean enablePollingforSSAI = false; // set to true if you want to poll for vast
MMSmartStreamingExo2.getInstance().initNewStream("Extracted MediaURL from Nowtilus SSAI streamURL",enablePollingforSSAI,isLive);
}

STEP 7: Add Macro Parameters API

getMacros() API returns the JSONObject which contains all Macros that needs to be substituted in Tracking Urls. You can add any new Macros to added in getMacros() API

public JSONObject getMacros() {
  JSONObject jsonObject = new JSONObject();
  JSONObject cmd = new JSONObject();
  try{
    cmd.put("md_dvb","OPPO");
    cmd.put("md_dvm","CPH2127");
    cmd.put("md_osv","11");
    cmd.put("md_hr","16");
    cmd.put("md_min","43");
    cmd.put("md_nt","1");

  }
  catch (JSONException e){

  }

  try {
    jsonObject.put("ifa","681a8ba7-39f5-46d9-9a5a-c006b8fbb7d8");
    jsonObject.put("av","1.12.3");
    jsonObject.put("bz","video");
    jsonObject.put("ccb","9281c15a");
    jsonObject.put("trq","1645614813154");
    jsonObject.put("br","OPPO");
    jsonObject.put("mn","CPH2127");
    jsonObject.put("osv","11");
    jsonObject.put("dt","1");
    jsonObject.put("os","1");
    jsonObject.put("ai","com.qa1.test");
    jsonObject.put("vr","AN-1.12.4");
    jsonObject.put("seq","1");
    jsonObject.put("lt","0");
    jsonObject.put("LIMITADTRACKING","0");
    jsonObject.put("ADTYPE","video");
    jsonObject.put("CACHEBUSTING","9281c15a");
    jsonObject.put("ap","1");
    jsonObject.put("TIMESTAMP","2022-02-23T16:43:33.154+0530");
    jsonObject.put("lc","eng_US");
    jsonObject.put("ai","com.qa1.test");
    jsonObject.put("APPBUNDLE","com.qa1.test");
    jsonObject.put("sh","1440");
    jsonObject.put("sw","720");
    jsonObject.put("ua","Mozilla/5.0 (Linux; Android 11; CPH2127 Build/RKQ1.201217.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/98.0.4758.101 Mobile Safari/537.36");
    jsonObject.put("DEVICEUA","Mozilla/5.0 (Linux; Android 11; CPH2127 Build/RKQ1.201217.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/98.0.4758.101 Mobile Safari/537.36");
    jsonObject.put("cmd",cmd);
  } catch (JSONException e) {

  }
  return jsonObject;
}

STEP 8: Subscribe to AD EVENTS and Pass the Macros to SSAI .

Passing Macros to SSAI with the help of setMacroSubstitution() API. getMacros() API will return the Macros in JSON format.

MMSmartStreamingNowtilusSSAIPlugin mmSmartStreamingNowtilusSSAIPlugin = MMSmartStreamingExo2.getInstance().getSSAIAdManager();

//passing Macros to SSAI using setMacroSubstitution
obj.setMacroSubstitution(getMacros())

//Subscribing to AD Events
MMSSAIEventsListeners mmssaiEventsListeners = new MMSSAIEventsListeners() {
  @Override
  public void onAdImpression(mmAd ssaiAdInfo) {
  }

  @Override
  public void onAdComplete(mmAd ssaiAdInfo) {
  }
  @Override
  public void onCueTimelineEnter(mmAd ssaiAdInfo) { 
  }

  @Override
  public void onCueTimelineExit(mmAd ssaiAdInfo) {  
  }

  @Override
  public void onCueTimelineAdded(mmAdTimelineInfo timelineInfo) {  
  }
};
mmSmartStreamingNowtilusSSAIPlugin.addListener(mmssaiEventsListeners);

List of AD EVENTS

onAdImpression
onAdStarted
onAdFirstQuartile
onAdMidpoint
onAdThirdQuartile
onAdProgress
onAdComplete
onCueTimelineAdded 
onCueTimelineEnter
onCueTimelineExit

You can use the below commands from inside any of the AD Events(listed above) that you subscribe to.

  1. ssaiAdInfo.getTotalAds()- returns a int which signifies the number of Ads in the current Ad break.

  2. ssaiAdInfo.getClickTrackingURLs()-returns the click tracking URLs as a List<String>.

  3. ssaiAdInfo.getClickThroughURLs() -returns the clickthrough URLs as a List<String>.

  4. ssaiAdInfo.getAdSkipOffset()- returns the AD offset in seconds.

  5. ssaiAdInfo.getCompleteTrackers() - returns the AD Complete Tracking URLs as a List<String>.

  6. ssaiAdInfo.getMidpointTrackers() - returns the AD Midpoint Tracking URLs as a List<String>.

  7. ssaiAdInfo.getThirdQuartileTrackers() - returns the AD ThirdQuartile Tracking URLs as a List<String>.

  8. ssaiAdInfo.getFirstQuartileTrackers() - returns the AD FirstQuartile Tracking URLs as a List<String>.

  9. ssaiAdInfo.getImpressionTrackers() - returns the AD Impression URLs as a List<String>.

  10. ssaiAdInfo.getAdIndex() - returns the index of the current AD in the AD break.

Step 10 : Get SDK Version Information

MMSmartStreamingExo2.getVersion() - returns the information about the version of SDK using.

Sample Application

The Sample Application for Exoplayer with Nowtilus SSAI can be donwloaded from

sdk.mediamelon.com/<Customer ID>/Android/ExoPlayer_2.11.8.zip

sdk.mediamelon.com/<Customer ID>/Android/ExoPlayer_2.12.2.zip

Complete Integration

Inside onCreate method

MMSmartStreamingExo2.getInstance().setContext(getApplicationContext()); //Please make sure to provide the application's context here, and not the activity's context

Inside the initializePlayer() method


MMSmartStreamingExo2.getInstance().setPlayer(player);
MMSmartStreamingExo2.getInstance().vastURLfromApplication ="extracted vastURL from the NOwtilus SSAI URL";
boolean enablePollingforSSAI = false; // set to true if you want to poll for vast
MMSmartStreamingExo2.getInstance().initNewStream("Extracted MediaURL from Nowtilus SSAI streamURL",enablePollingforSSAI);

//get the SSAI Admanager and subscribe to events and send Macros
MMSmartStreamingNowtilusSSAIPlugin mmSmartStreamingNowtilusSSAIPlugin = MMSmartStreamingExo2.getInstance().getSSAIAdManager();

mmSmartStreamingNowtilusSSAIPlugin.setMacroSubtitution(getMacros);

MMSSAIEventsListeners mmssaiEventsListeners = new MMSSAIEventsListeners() {
  @Override
  public void onAdImpression(mmAd ssaiAdInfo) {
  }

  @Override
  public void onAdComplete(mmAd ssaiAdInfo) {
  }
  @Override
  public void onCueTimelineEnter(mmAd ssaiAdInfo) { 
  }

  @Override
  public void onCueTimelineExit(mmAd ssaiAdInfo) {  
  }

  @Override
  public void onCueTimelineAdded(mmAdTimelineInfo timelineInfo) {  
  }
};
mmSmartStreamingNowtilusSSAIPlugin.addListener(mmssaiEventsListeners);

Last updated