The player application must register the SDK and provide player information once when the application launches. Please note that values provided in this integration step persist across video sessions. This is typically done when the player itself is initialized.
You can check SDK registration status with getRegistrationStatus(). If the registration is not complete, use the registerMMSmartStreaming() to complete the registration.
Perform registration tasks by modifying the onCreate() method in $EXOPROJECT/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
The enableLogTrace() feature should be enabled for testing during the integration process. Set this to False before releasing the player to production
publicvoidonCreate(Bundle savedInstanceState) {... }else { trackSelectorParameters =new DefaultTrackSelector.ParametersBuilder().build();clearStartPosition(); }//<MMSmartStreaming 2b>Log.d("SmartStreamingIntgr",MMSmartStreamingExo2.getVersion());MMSmartStreamingExo2.enableLogTrace(true); //set to "false" before releasing player to productionif (MMSmartStreamingExo2.getRegistrationStatus() ==false){ //Check if it is the first time Registration process is done MMSmartStreamingExo2.registerMMSmartStreaming($PLAYERNAME, $CUSTOMERID, $SUBSCRIBERID, $DOMAINNAME, $SUBSCRIBERTYPE, $SUBSCRIBERTAG);
MMSmartStreamingExo2.reportPlayerInfo("CustomPlayerName",ExoPlayerLibraryInfo.VERSION,"1.0"); MMSmartStreamingExo2.getInstance().setContext(getApplicationContext()); //Please make sure to provide the application's context here, and not the activity's context
}// </MMSmartStreaming 2b> }
Step 3: Initialize Session & Report User Intent to Playback
The SDK must be initialized at the start of each video session. Initialization includes setting the application context, initializing the playback session, and indicating the intent for playback with the SDK.
Provide application context to SDK by modifying the createTopLevelMediaSource() method in $EXOPROJECT/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
protectedbooleaninitializePlayer() {if (player ==null) {Intent intent =getIntent();.........// after player is initialised and not null anymoreString mediaUrl ="get the mediaURL from your application"String assetId ="assetID"; //enter you assetId hereString assetName ="assetNAME"; // enter your assetname hereString videoId ="videoID"; // enter your videoId hereContentMetadata cm =newContentMetadata();String episodeNumber ="EpisodeNumber";String season ="Season";String genre ="Genre";String drmProtection ="drmProtection";String contentType ="contentType";String title ="Title";cm.videoId=videoId;cm.seriesTitle=title;cm.season=season;cm.genre=genre;cm.episodeNumber=episodeNumber;cm.drmProtection=drmProtection;cm.contentType=contentType;cm.assetName=assetName;cm.assetId=assetId;JSONObject contentMetadata =cm.getJSONObject();//optional content metadata MMSmartStreamingExo2.getInstance().initializeSession(player, MMQBRMode.QBRModeDisabled, mediaUrl, null, assetId, assetName, videoId,null,contentMetadata);
MMSmartStreamingExo2.getInstance().reportUserInitiatedPlayback();......}
Step 4: Report User Intent to Playback
When the user presses the play button for the first time to start the playback, or in autoplay mode when a player is fed with a content URL to load the session, reportUserInitiatedPlayback() should be called. In the demo application, autoplay is “on”, so let's call this API just before player.prepare()
In $EXOPROJECT/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java