Copy mmsmartstreaming-media3.aar provided in the release package for the Media3 project. Example $MEDIA3PROJECT/demos/main/mmsmartstreaming-media3.aar .
Add the following library to $MEDIA3PROJECT/demos/main/build.gradle :-
Add network permissions to $MEDIA3PROJECT/demos/main/src/main/AndroidManifest.xml
The player application must register the SDK and provide player information once the 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.
The enableLogTrace() feature should be enabled for testing during the integration process. Set this to False before releasing the player to production.
CUSTOMER_ID is your MediaMelon assigned Customer ID. If you do not know your Customer ID contact MediaMelon at [email protected].
Step 5: Report Ended State
In $MEDIA3PROJECT/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java
protected boolean initializePlayer() {
if (player == null) {
Intent intent = getIntent();
...
// after the player is initialized and the player instance is not null
initializeMediaMelon();
...
}
void initializeMediaMelon(){
MMSmartStreamingMedia3.enableLogTrace(false);
if (MMSmartStreamingMedia3.getRegistrationStatus() == false)
{
MMSmartStreamingMedia3.setContext(getApplicationContext()); //Please make sure to provide the application's context here, and not the activity's context
boolean hashSubscriberId = true;
MMSmartStreamingMedia3.registerMMSmartStreaming("PLAYER_NAME", "CUSTOMER_ID", "SUBSCRIBER_ID", "DOMAIN_NAME", "SUBSCRIBER_TYPE", "SUBSCRIBER_TAG", hashSubscriberId);
MMSmartStreamingMedia3.reportPlayerInfo("PLAYER_BRAND", "PLAYER_MODEL", "PLAYER_VERSION");
MMSmartStreamingMedia3.reportAppInfo("APP_NAME","APP_VERSION");
MMSmartStreamingMedia3.reportExperimentName("EXPERIMENT_NAME");
MMSmartStreamingMedia3.setDeviceInfo("DEVICE_MARKETING_NAME");
}
String streamURL = 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();
MMSmartStreamingMedia3.reportCustomMetadata("KEY1","VALUE1");
MMSmartStreamingMedia3.reportCustomMetadata("KEY2","VALUE2");
boolean isLive = false;
MMSmartStreamingMedia3.reportViewSessionID("VIEW_SESSION_ID");
MMSmartStreamingMedia3.initializeSession(player, streamURL, contentMetadata, isLive);
MMSmartStreamingMedia3.reportUserInitiatedPlayback();
}
private void releasePlayer() {
if (player != null) {
player.release();
player = null;
MMSmartStreamingMedia3.reportPlayerState(false, Player.STATE_ENDED);
}
}