Media3 IMA SDK Integration Document

This guide provides detailed instructions on integrating the Android MediaMelon IMA SDK with the Media3 player.

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

Step 8: Report Player Resolution

Step 9: Report Custom Errors

Step 10: Report Ended State

Step 11: Enable IMA/DAI Ad tracking

Step 1: Prerequisites

  • Media3 sample application.

  • MediaMelon Media3 SDK Maven dependencies or the provided AAR file is 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:

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

Using AAR:

  1. Copy mmsmartstreaming.aar provided in the release package for the Media3 project. Example $MEDIA3PROJECT/demos/main/mmsmartstreaming.aar .

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

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

Step 3: Import Packages

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

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.

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].

For Custom Metadata, first, provide the mapping in the SmartSight dashboard under the settings section and send the values to the SDK accordingly.

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

Make sure that enableCustomErrorReporting is set to true for this to be able to report errors

Step 10: Report Ended State

Report ENDED state in PlayerActivity when playback ends.

If not reported at the end of the playback, it may reflect a longer playtime.

Step 11: Enable IMA/DAI Ad tracking

Add the following steps to enable IMA/DAI Ad tracking

11.a: IMA Ad Tracking

Alternate method for IMA ad tracking

11.b: DAI Ad Tracking

The function onAdsManagerLoaded is part of AdsLoader.AdsLoadedListener

Last updated