Castlabs Player Android v4.2.49 with Nowtilus SSAI

Step by step guide for integrating the MediaMelon Castlabs Player SDK with Nowtilus SSAI to a Castlabs Player based sample application

STEP 0

Please find the Sample reference application in the Release Notes document. The demo application is available under mediamelon_demo.zip

https://mediamelon-builds.s3.amazonaws.com/MM-RELEASE-BUILDS/1922042005/CastlabsPlayer_Android/2022-11-23/demos.zip

STEP 1

Add the following lines to access the SDK

In the Sample Application the following imports are added in SimplePlaybackDemo.java

//MM 1
import com.mediamelon.smartstreaming.mmAd;
import com.mediamelon.smartstreaming.mmAdTimelineInfo;
import com.mediamelon.smartstreaming.MMSSAIEventsListeners;
import com.mediamelon.smartstreaming.MMSmartStreaming;
import com.mediamelon.smartstreaming.MMSmartStreamingPrestoPlayAdaptor;
// MM1

STEP 2

startMediaMelonSDK() API calls all MediaMelon SDK integration API's. To Integrate MediaMelon SDK please call startMediaMelonSDK(). And register Mediamelon SDK using your assigned customerID in StartMediaMelon API. Please refer code block below.

        //MM 2
        boolean sdkIntegration = false; // whether to check SDK integration   
        public void startMediaMelonSDK(){
	        //MediaMelon Castlabs Player Integration
		//MM2A
			sdkIntegration = true;
		        final PlayerController pc = playerView.getPlayerController();
			mmSmartStreamingPrestoPlayAdaptor = new MMSmartStreamingPrestoPlayAdaptor ( getApplicationContext(), pc);
		
		
			mmSmartStreamingPrestoPlayAdaptor.enableLogTrace(true); // Set false in production
			if (!MMSmartStreaming.getRegistrationStatus()) {
				mmSmartStreamingPrestoPlayAdaptor.registerMMSmartStreaming("$PLAYERNAME", "$CUSTOMERID", "$SUBSCRIBERID", "$DOMAINNAME", "$SUBSCRIBERTYPE", "$SUBSCRIBERTAG");
			}
		
			Log.d("MM Reg", "MM Reg:" + MMSmartStreaming.getRegistrationStatus());
			mmSmartStreamingPrestoPlayAdaptor.reportPlayerInfo("CASTLABS", "A1", "1.0");
		//MM2A
	}
	//MM2

Parameters passed in Registration call

VariableDescription

$PLAYERNAME

Player Name as in Castlabs Player

$CUSTOMERID

String containing your MediaMelon-assigned Customer ID.

$SUBSCRIBERID

String containing your subscriber’s ID. If you do not use subscriber IDs, leave it as it is.

$DOMAINNAME

String containing your section of your subscriber or assets. (Optional)

$SUBSCRIBERTYPE

String containing the subscriber type (e.g. “Free”, “Paid”). If you do not use subscriber types, leave it as it is.

$SUBSCRIBERTAG

String containing an additional subscriber-specific information. This is sent in clear (not hashed) to SmartSight and it is advised to not send sensitive information in this field.

STEP 3

3.1 Initialize the SDK.

3.2 Intialize SSAI tracking

3.3 Start the SDK

Add the below lines following the registration to enable the Nowtilus SSAI Ad Manager in startMediaMelonSDK() API. Please refer the code below.

NOTE - boolean enablePollingforSSAI variable indicates whether the Mediamelon SDK needs to poll for the VAST URL or not. Please set it to true in case of Castlabs Player.

       public void startMediaMelonSDK(){
       
          //MM2A
             ....
          //MM2A
          
          //MM2B
          // 3.1 Initialize SDK
          // Asset data. This needs to be provided. In case you do not want to use this
          // sample block can be used as is 
              JSONObject obj = new JSONObject();
   				try {
   					obj.put("assetName","SampleLiveStream") ;
   					obj.put("assetId","0001") ;
   					obj.put("videoId","0001") ;
   				} catch (JSONException e) {
   					e.printStackTrace(); }			
              mmSmartStreamingPrestoPlayAdaptor.initialize(mediaURL,obj);
          
             // 3.2 Add SSAI 
             // mMyUri - Media URL
             // vastURL - URL for VAST
             // isLive - True for Live streams and false for VOD
             // The last parameter setupNowtilusAdManager enablePollingforSSAI is alsways set to true
          
             mmSmartStreamingPrestoPlayAdaptor.setupNowtilusAdManager(mediaURL, vastURL, true, true);
             ....
             // 3.3 Start the SDK
             mmVoPlayerAdapter.reportUserInitiatedPlayback();
             //MM2B
         }
         //MM2

STEP 4

Subscribe to AD EVENTS in startMediaMelon() API. Please refer code block below

     //MM 2
     public void startMediaMelonSDK(){
         
         //MM2A
          ......
         //MM2A
         
         //MM2B
          .......
         //MM2B
         
         
         //MM2C
         //subscribe to AD EVENTS
         MMSSAIEventsListeners mmssaiEventsListeners = new MMSSAIEventsListeners() {
			@Override
			public void onAdImpression(mmAd ssaiAdInfo) {
				Log.d("APP SSAI", "onAdImpression:" + ssaiAdInfo.adId);    }

			@Override
			public void onAdComplete(mmAd ssaiAdInfo) {
				Log.d("APP SSAI", "onAdComplete:" + ssaiAdInfo.adId);
			}

			@Override
			public void onCueTimelineAdded(mmAdTimelineInfo timelineInfo) {
				Log.d("APP SSAI", "onCueTimelineAdded totalAds: " + timelineInfo.totalAds);
			}

			@Override
			public void onCueTimelineEnter(mmAd ssaiAdInfo) {
				Log.d("APP SSAI", "onCueTimelineEnter:" + ssaiAdInfo.adId);
			}

			@Override
			public void onCueTimelineExit(mmAd ssaiAdInfo) {
				Log.d("APP SSAI", "onCueTimelineExit:" + ssaiAdInfo.adId);
			}
		};
          mmSmartStreamingPrestoPlayAdaptor.getSSAIAdManager().addListener(mmssaiEventsListeners);
         //MM2C
    }
    //MM2

STEP 5

ADD API for stopping MediaMelon SDK.To stop MediaMelon SDK please call stopMediaMelonSDK(). Please refer code block below

    //MM3
        public void stopMediaMelonSDK(){
           if(sdkIntegration) mmSmartStreamingPrestoPlayAdaptor.closeMediaMelonSDK(); 
        }
    //MM3
    

List of AD EVENTS

onAdImpression
onAdStarted
onAdFirstQuartile
onAdMidpoint
onAdThirdQuartile
onAdProgress
onAdComplete
onCueTimelineAdded 
onCueTimelineEnter
onCueTimelineExit
Event CallbackDescription

onAdImpression

Fired when an Ad Impression occurs

onAdStarted

Fired when Ad starts playing

onAdFirstQuartile

Fired when Ad playback reaches the First Quartile point

onAdMidpoint

Fired when Ad playback reaches the Midpoint

onAdThirdQuartile

Fired when Ad playback reaches the Third Quartile point

onAdProgress

Fired every second during Ad Playback, used to track Ad Playback progress

onAdComplete

Fired when Ad Playback completes

onCueTimelineAdded

Fired when an Ad break information gets added

onCueTimelineEnter

Fired when an Ad break ( which can contain multiple Ads) starts

onCueTimeLineExit

Fired when an Ad break ( which can contain multiple Ads) ends

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.

Last updated