MediaMelon
  • MediaMelon SDK Integration
  • MediaMelon SDK Events
  • MediaMelon Player SDK Integration
    • React Native
      • React Native Video v5.2.0 with Mediamelon SDK
      • React Native Video v6.4.2 with Mediamelon SDK
    • Web SDK
      • VideoJS Web with Mediamelon Analytics
      • VideoJS Web with Google DAI
      • Shaka Player Web v4
      • MediaMelon Web Kaltura Player Plugin Integration Document
      • NexPlayer Web v4
      • THEOPlayer Web
      • JWPlayer Web
      • Radiant Player Web
      • ChromeCast Player
      • HLSJS Player Web
      • HbbTV SDK
      • Comcast PDK 6
      • Bitmovin Web Player
      • HTML5 Player Web
      • Flow Player Web
      • DashJS Player Web
      • Castlabs Player Web
      • Cordova Plugin Toast (Smart TV)
      • Custom Player Web SDK
      • Plyr Player Web with MediaMelon Analytics
      • React Player SDK with IMA
    • Android SDK
      • App Analytics SDK
      • Bitmovin Android v3.73 with Content Provider Metrics
      • Exoplayer v2.13.2 integration with MediaMelon SDK
      • Exoplayer v2.17.1 with Mediamelon SDK
      • Exoplayer v2.12.2 integration with MediaMelon SDK
      • EXOPlayer-Android(V2.14.2) MediaMelon SDK with Google IMA DAI
      • EXOPlayer-Android(V2.17.1) MediaMelon SDK with Google IMA DAI
      • Exoplayer v2.11
      • Exoplayer v2.18.1 with Mediamelon SDK
      • Theoplayer v6.0.0 with Mediamelon SDK
      • Theoplayer v4.12.6 with Mediamelon SDK
      • Theoplayer v7.5.0 with Mediamelon SDK
      • Exoplayer v2.13.3 integration with MediaMelon SDK
      • Kaltura Android Player Integration with Mediamelon SDK
      • Media3 v1.3.0 and ExoPlayer 2.19.1 with MediaMelon SDK
      • Media3 v1.3.1 with MediaMelon SDK
      • MediaMelon Android Media3 v1.1.1 SDK Integration Document
      • Media3Player-Android(V1.3.0) MediaMelon SDK with Google IMA
    • Roku SDK
      • Roku SDK
      • Roku with RAF SDK
      • Roku with IMA SDK
    • iOS SDK
      • AVPlayer (Cocoapods)
      • AVPlayer with Google DAI SDK ( Framework )
      • AVPlayer Quality Of Experience SDK
      • AVPlayer Generic Framework
      • AVPlayer with Google DAI (Cocoapods)
      • Bitmovin iOS v3.44 with Content Provider Metrics
      • THEOPlayer XCFramework
      • THEOplayer (Cocoapods)
      • MediaMelon iOS Kaltura Player Plugin Integration Document
    • tvOS SDK
      • AVPlayer tvOS XCFramework
      • THEOPlayer tvOS XCFramework
    • Toast SDK
    • Custom Player C++ SDK
    • C++ SDK QoE Ads
    • Ad Integrations
      • Google IMA
      • FreeWheel
      • ServerSide.AI
  • SmartSight Analytics
    • Product Features
    • QBR Streaming
  • SmartSight API's
    • API Overview
      • Metric and Dimensions Dictionary
      • General Guidelines
      • Video Experience
      • Ad Experience
      • Smartquery Insights
      • Errors
      • Alerts
    • Use-case dictionary
Powered by GitBook
On this page
  • Prerequisites
  • Step 1: Set up the build environment
  • Step 2: Register SDK
  • Step 3: Registration, Initialize Session & Report User Intent to Playback
  • Step 4: Report ended state when the player instance is released

Was this helpful?

  1. MediaMelon Player SDK Integration
  2. Android SDK

Media3 v1.3.0 and ExoPlayer 2.19.1 with MediaMelon SDK

This guide is for integrating MediaMelon SDK with Media3 v1.3.0 and Exoplayer v2.19.1

PreviousKaltura Android Player Integration with Mediamelon SDKNextMedia3 v1.3.1 with MediaMelon SDK

Last updated 1 year ago

Was this helpful?

Prerequisites

  • Meida3 - v1.3.0 .

  • MediaMelon SmartSight SDK Maven dependencies or the provided smartstreaming_release.aar AAR file is necessary.

Step 1: Set up the build environment

$MEDIA3PROJETC = {Media3 - v1.3.0}

The SDK files should be added to the build environment and the required network permissions should be enabled.

Using Maven:

  1. Add MediaMelon Maven dependency to $MEDIA3PROJETC/demos/main/build.gradle

    dependencies {
       ...
      //<!-- <MMSmartStreaming 1b> -->
      implementation 'com.github.MediamelonSDK:mm-sdk-media3-android:1.0.0'
      implementation 'com.google.android.exoplayer:exoplayer-core:2.19.1'
      implementation 'androidx.media3:media3-exoplayer:1.3.0'
      //<!-- </MMSmartStreaming 1b> --> 
    }

Using AAR:

  1. Copy smartstreaming-release.aar provided with the release package to the Media3 project. Example $MEDIA3PROJETC/demos/main/smartstreaming-release.aar

  2. Add the following library to $MEDIA3PROJETC/demos/main/build.gradle :-

dependencies {
  ...
  //<!-- <MMSmartStreaming 1b> -->
  api files ('smartstreaming-release.aar')
  implementation 'com.google.android.exoplayer:exoplayer-core:2.19.1'
  implementation 'androidx.media3:media3-exoplayer:1.3.0'
  //<!-- </MMSmartStreaming 1b> --> 
}

To use MediaMelon SDK you have to implement both media3 and Exoplayer dependencies.

Add network permissions to $MEDIA3PROJETC/demos/main/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<!-- <MMSmartStreaming 1c> -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- </MMSmartStreaming 1c> -->

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.

Step 2a: Import packages

$MEDIA3PROJETC/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java

// <MMSmartStreaming 2a>
import com.mediamelon.qubit.ep.ContentMetadata;
import com.mediamelon.smartstreaming.MMQBRMode;
import com.mediamelon.smartstreaming.MMSmartStreamingAdapter;
import com.mediamelon.smartstreaming.MMSmartStreamingFactory;
// </MMSmartStreaming 2a>

Step 2b: Setup MediaMelon Adapter Object

Setup MediaMelon Adapter Object before onCreate() method in $MEDIA3PROJETC/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java

...

//<MMSmartStreaming 2b>
MMSmartStreamingAdapter mmSmartStreamingAdapter;
// </MMSmartStreaming 2b> 

public void onCreate(Bundle savedInstanceState) {
  ... 
}

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

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>
 }

Step 4: Report ended state when the player instance is released

In $MEDIA3PROJETC/demos/main/src/main/java/androidx/media3/demo/main/PlayerActivity.java

private void releasePlayer() {
    if (player != null) {
      updateTrackSelectorParameters();
      updateStartPosition();
      debugViewHelper.stop();
      debugViewHelper = null;
      player.release();
      player = null;
      mediaSource = null;
      trackSelector = null;
      // <MMSmartStreaming 4> Start
      mmSmartStreamingAdapter.reportPlayerState(false, Player.STATE_ENDED);
      // </MMSmartStreaming 4> End
    }
  }

sample application