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.
Perform registration tasks by modifying the onCreate() method in $EXOPROJECT/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
set the doHash variable for in registerMMSmarttreaming() API subscriberId hashing,set to true for hasing else false
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 doneMMSmartStreamingExo2.setDeviceInfo($DEVICE_MARKETING_NAME);MMSmartStreamingExo2.registerMMSmartStreaming($PLAYERNAME, $CUSTOMERID, $SUBSCRIBERID, $DOMAINNAME, $SUBSCRIBERTYPE, $SUBSCRIBERTAG,$doHash);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 contextMMSmartStreamingExo2.getInstance().reportAppInfo($APP_NAME,$APP_VERSION);MMSmartStreamingExo2.getInstance().reportVideoQuality($VIDEO_QUALITY); }MMSmartStreamingExo2.disableManifestsFetch(true); // pass true if you want to disable Manifests Fetch // </MMSmartStreaming 2b> }
overridefunonCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main) progressBar =findViewById(R.id.progressBar) titleTv =findViewById(R.id.title)//MM// //<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.setDeviceInfo("Samsung Prime A1") MMSmartStreamingExo2.getInstance() .setContext(applicationContext) //Please make sure to provide the application's context here, and not the activity's context// in the below line replace "199493832" with your customerID MMSmartStreamingExo2.registerMMSmartStreaming("\$PLAYERNAME","199493832","\$SUBSCRIBERID","\$DOMAINNAME","\$SUBSCRIBERTYPE","\$SUBSCRIBERTAG",true ) MMSmartStreamingExo2.reportPlayerInfo("CustomPlayerName", ExoPlayerLibraryInfo.VERSION,"1.0" ) MMSmartStreamingExo2.getInstance() .setContext(applicationContext) //Please make sure to provide the application's context here, and not the activity's context MMSmartStreamingExo2.getInstance().reportCustomMetadata("key", "value") MMSmartStreamingExo2.reportAppInfo("LifeTime", "1.2.3") MMSmartStreamingExo2.reportVideoQuality("4K-HDR") } MMSmartStreamingExo2.disableManifestsFetch(true) // pass true if you want to disable Manifests Fetch// </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.
set isLive variable in initializeSession() call , set true for live stream else false
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//(optional) add custom tagsMMSmartStreamingExo2.getInstance().reportCustomMetadata("key","value");MMSmartStreamingExo2.getInstance().initializeSession(player,MMQBRMode.QBRModeDisabled, mediaUrl,null, assetId, assetName, videoId,null,contentMetadata,isLive);MMSmartStreamingExo2.getInstance().reportUserInitiatedPlayback();......}
protected boolean initializePlayer() {val mediaUrl: String=" String mediaUrl = "get the mediaURL from your application";//getting the mediaURL from the application val assetId = "assetID" //enter you assetId here val assetName = "assetNAME" // enter your assetname here val videoId = "videoID" // enter your videoId here val cm = ContentMetadata() val episodeNumber = "EpisodeNumber" val season = "Season" val genre = "Genre" val drmProtection = "drmProtection" val contentType = "contentType" val 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 val contentMetadata = cm.jsonObject //optional content metadata //(optional) add custom tags MMSmartStreamingExo2.getInstance().reportCustomMetadata("key", "value") MMSmartStreamingExo2.getInstance().initializeSession( player, MMQBRMode.QBRModeDisabled, mediaUrl, null, assetId, assetName, videoId, null, contentMetadata, false ) MMSmartStreamingExo2.getInstance().reportUserInitiatedPlayback();}
Step 4: Report ended state when the player instance is released
In $EXOPROJECT/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
privatefunreleasePlayer() { isPlayerPlaying = exoPlayer.playWhenReady playbackPosition = exoPlayer.currentPosition currentWindow = exoPlayer.currentMediaItemIndex//MM MMSmartStreamingExo2.getInstance().reportPlayerState(false, Player.STATE_ENDED) exoPlayer.release() }// if there is no releasePlayer API in your sample application, you can use onDestroy ListeneroverridefunonDestroy() {super.onDestroy() Log.d(TAG, "onSaveInstanceState: "+ player.currentPosition)//MM//MM MMSmartStreamingExo2.getInstance().reportPlayerState(false, Player.STATE_ENDED) }