Copy smartstreaming-release.aar provided with the release package to the Media3 project. Example $MEDIA3PROJETC/demos/main/smartstreaming-release.aar
Add the following library to $MEDIA3PROJETC/demos/main/build.gradle :-
To use MediaMelon SDK you have to implement both media3 and Exoplayer dependencies.
Add network permissions to $MEDIA3PROJETC/demos/main/src/main/AndroidManifest.xml
Step 2: Register SDK
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.
Setup MediaMelon Adapter Object before onCreate() method in $MEDIA3PROJETC/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java
Step 3: Registration, Initialize Session & Report User Intent to Playback
The player application must register the SDK and provide player information once after player is initialized. Please note that values provided in this integration step persist across video sessions.
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 the isLive variable in initializeSession() call , set true for live stream else false.
The enableLogTrace() feature should be enabled for testing during the integration process. Set this to False before releasing the player to production
Step 4: Report ended state when the player instance is released
In $MEDIA3PROJETC/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java
protected boolean initializePlayer() {
if (player == null) {
Intent intent = getIntent();
...
// after player is initialised and not null anymore
initializeMediaMelon();
...
}
void initializeMediaMelon(){
// <MMSmartStreaming 3>
mmSmartStreamingAdapter = MMSmartStreamingFactory.getInstance(player);
mmSmartStreamingAdapter.enableLogTrace(true); //set to "false" before releasing player to production
if (mmSmartStreamingAdapter.getRegistrationStatus() == false)
{ //Check if it is the first time Registration process is done
mmSmartStreamingAdapter.setContext(getApplicationContext()); //Please make sure to provide the application's context here, and not the activity's context
mmSmartStreamingAdapter.registerMMSmartStreaming("PLAYER_NAME", "CUSTOMER_ID", "SUBSCRIBER_ID", "DOMAIN_NAME", "SUBSCRIBER_TYPE", "SUBSCRIBER_TAG");
mmSmartStreamingAdapter.reportPlayerInfo("PLAYEER_BRAND", "PLAYER_MODEL", "PLAYER_VERSION");
mmSmartStreamingAdapter.reportAppInfo("APP_NAME","APP_VERSION");
mmSmartStreamingAdapter.reportVideoQuality("VIDEO_QUALITY");
mmSmartStreamingAdapter.setDeviceInfo("DEVICE_MARKETING_NAME");
}
String mediaUrl = String.valueOf(mediaItems.get(0).localConfiguration.uri); //getting the mediaURL from the application
ContentMetadata cm = new ContentMetadata();
cm.assetName="ASSET_NAME";
cm.assetId="ASSET_ID";
cm.videoId="VIDEO_ID";
cm.seriesTitle="SERIES_TITLE";
cm.season="SEASON";
cm.genre="GENRE";
cm.episodeNumber="EPISODE_NUMBER";
cm.drmProtection="DRM_PROTECTION";
cm.contentType="CONTENT_TYPE";
JSONObject contentMetadata = cm.getJSONObject();
mmSmartStreamingAdapter.reportCustomMetadata("KEY1","VALUE1");
mmSmartStreamingAdapter.initializeSession(MMQBRMode.QBRModeDisabled, mediaUrl, null, null, contentMetadata, false);
mmSmartStreamingAdapter.reportUserInitiatedPlayback();
// <MMSmartStreaming 3>
}