ExoPlayer SDK Integration Document
This guide provides detailed instructions on integrating the Android MediaMelon SDK with the ExoPlayer.
Step 1: Prerequisites
Step 2: Set up the build environment
Step 3: Import Packages
Step 4: Register and Initialise SDK
Step 5: Report Experiment Name
Step 6: Report Sub-Property Id
Step 7: Report View Session Id
Step 8: Report Player Resolution
Step 9: Report Custom Errors
Step 10: Report Ended State
Step 1: Prerequisites
MediaMelon ExoPlayer SDK Maven dependencies or the provided AAR file are necessary.
Step 2: Set up the build environment
The SDK files should be added to the build environment and the required network permissions should be enabled.
Using Maven:
Add MediaMelon ExoPlayer Maven dependency to
/build.gradle
dependencies {
...
implementation 'com.github.MediamelonSDK:mm-android-sdk-exoplayer:2.2.0'
}
Using AAR:
Copy
mmsmartstreaming.aar
provided in the release package. Example$project/main/mmsmartstreaming.aar
.
Add the following library to
build.gradle
:-
dependencies {
...
api files ('mmsmartstreaming.aar')
}
Add network permissions to AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Step 3: Import Packages
Import dependencies in PlayerActivity.java
import com.mediamelon.qubit.ep.ContentMetadata
import com.mediamelon.smartstreaming.exoplayer.MMSmartStreamingAdapter
import com.mediamelon.smartstreaming.exoplayer.MMSmartStreamingFactory
Step 4: Register and Initialise SDK
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.
public void initMediaMelon() {
MMSmartStreamingAdapter mmSmartStreamingAdapter = MMSmartStreamingFactory.getInstance();
mmSmartStreamingAdapter.enableLogTrace(true);
if (!mmSmartStreamingAdapter.getRegistrationStatus()) {
mmSmartStreamingAdapter.setContext(requireContext().getApplicationContext()); // 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", hashSubscriberId);
mmSmartStreamingAdapter.reportPlayerInfo("PLAYER_BRAND", "PLAYER_MODEL", "PLAYER_VERSION");
mmSmartStreamingAdapter.reportBasePlayerInfo("BASE_PLAYER_NAME", "BASE_PLAYER_VERSION");
mmSmartStreamingAdapter.reportAppInfo("APP_NAME", "APP_VERISON");
mmSmartStreamingAdapter.setDeviceInfo("DEVICE NAME");
}
ContentMetaData contentMetaData = new ContentMetaData();
contentMetaData.assetName = "ASSET_NAME";
contentMetaData.assetId = "ASSET_ID";
contentMetaData.videoId = "VIDEO_ID";
contentMetaData.seriesTitle = "TITLE";
contentMetaData.season = "SEASON";
contentMetaData.genre = "GENRE";
contentMetaData.episodeNumber = "EPISODE_NUMBER";
contentMetaData.drmProtection = "DRM_PROTECTION";
contentMetaData.contentType = "CONTENT_TYPE";
mmSmartStreamingAdapter.initializeSession(Companion.getPlayer(), contentMetaData, isLive);
mmSmartStreamingAdapter.reportUserInitiatedPlayback();
mmSmartStreamingAdapter.reportCustomMetadata("custom_1", "VALUE_1");
mmSmartStreamingAdapter.reportCustomMetadata("custom_2", "VALUE_2");
}
Step 5: Report Experiment Name
Reporting Experiment name:
mmSmartStreamingAdapter.reportExperimentName("EXPERIMENT_NAME");
Step 6: Report Sub-Property Id
Reporting Sub-Property Id:
mmSmartStreamingAdapter.reportSubPropertyId("SUB_PROPERTY_ID");
Step 7: Report View Session Id
Reporting View Session Id:
mmSmartStreamingAdapter.reportViewSessionId("VIEW_SESSION_ID");
Step 8: Report Player Resolution
Reporting the resolution of the player:
mmSmartStreamingAdapter.reportPlayerResolution(playerWidth, playerHeight);
Step 9: Report Custom Errors(Optional)
mmSmartStreamingAdapter.enableCustomErrorReporting(true);
Report custom errors:
mmSmartStreamingAdapter.reportError("ERROR_CODE", "ERROR_MESSAGE", "ERROR_DESCRIPTION");
Step 10: Report Ended State
Report ENDED state in PlayerActivity
when playback ends.
private void releasePlayer() {
if (player != null) {
player.release();
player = null;
mmSmartStreamingAdapter.reportPlayerState(false, Player.STATE_ENDED);
}
}
Last updated