> For the complete documentation index, see [llms.txt](https://docs.mediamelon.com/mediamelon/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mediamelon.com/mediamelon/smartsight-player-sdk-integration/android/kaltura-sdk-integration-document.md).

# Kaltura SDK Integration Document

**Step 1:** [Prerequisites](#step-1-prerequisites)

**Step 2:** [Set up the build environment](#step-2-set-up-the-build-environment)

**Step 3:** [Include and Configure the MediaMelon Plugin](#step-3-include-and-configure-the-mediamelon-plugin)

### Step 1: Prerequisites

* Kaltura Player Playtkit  <https://github.com/kaltura/playkit-android>
* MediaMelon Kaltura Player Plugin  (com.github.MediamelonSDK:mm-KalturaPlayer:1.1.1)
* IMADAISample  from [https://github.com/kaltura/playkit-android-samples/tree/develop/](https://github.com/kaltura/playkit-android-samples/tree/develop/BasicPluginsSetup)
* Allsamples folder from <https://github.com/kaltura/playkit-android-samples/tree/develop/AllSamples> ( AllSamples folder and BasicPluginSetup need to be at the same level )

### Step 2: Set up the build environment&#x20;

The SDK files are added to the build environment and the required network permissions are enabled.&#x20;

1. Copy mediamelonplugin-release.aar provided with the release package to the libs folder ( create one if its not already there ) in the  BasicPluginsSetup project
2. Add the following library to `IMADAISample/app/build.gradle` :-

```java
dependencies {
  .
  .
  .
  //<!-- <MMSmartStreaming 1b> -->
   implementation 'com.github.MediamelonSDK:mm-KalturaPlayer:1.1.1'
  //<!-- </MMSmartStreaming 1b> -->
  
}
```

Add network permissions to `IMADAISample/app/manifests/AndroidManifest.xml`

```java
<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: Include and Configure the MediaMelon Plugin

The MediaMelon plugin needs to be configured . The following steps need to be executed.&#x20;

Step 3a: Import packages

The MediaMelon plugin package needs to be imported in the following file

`IMADAISample/app/com/kaltura/playkit/samples/imadaisample/MainActivity.java`

{% tabs %}
{% tab title="JAVA" %}

```java
import com.kaltura.playkit.plugins.mediamelon.*;
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
import com.kaltura.playkit.plugins.mediamelon.*
```

{% endtab %}
{% endtabs %}

#### Step 3b: Configure the Plugin

Add the following function createPluginConfigs in the file `IMADAISample/app/com/kaltura/playkit/samples/imadaisample/MainActivity.java`

{% tabs %}
{% tab title="JAVA" %}

```java
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //Initialize media config object.
        createMediaConfig();

        //Create plugin configurations.
        PKPluginConfigs pluginConfigs = createIMADAIPlugin();
        pluginConfigs = createMMPluginConfigs(pluginConfigs);

        //Create instance of the player with plugin configurations.
        player = PlayKitManager.loadPlayer(this, pluginConfigs);
.....
}

private PKPluginConfigs createMMPluginConfigs(PKPluginConfigs pkPluginConfigs) {
        //First register your SamplePlugin.
        PlayKitManager.registerPlugins(this, MediamelonPlugin.factory);

        //Initialize plugin configuration object.

        if(pkPluginConfigs == null) {
            //Initialize plugin configuration object.
            pkPluginConfigs = new PKPluginConfigs();
        }

        //Set jsonObject to the main pluginConfigs object.
        pkPluginConfigs.setPluginConfig(MediamelonPlugin.factory.getName(),  createJson() );

        //Return created and populated object.
        return pkPluginConfigs;
    }

// Json parameters for configuring plugin
private JsonObject createJson() {
        JsonObject optJson = new JsonObject();

        // Main config goes here.
        optJson.addProperty("customerId", "18410666590");
        optJson.addProperty("domainName", "EladDomain");
        optJson.addProperty("subscriberId", "SubscriberId");
        optJson.addProperty("subscriberType", "SubscriberType");
        optJson.addProperty("subscriberTag", "SubscriberTag");
        optJson.addProperty("doHash", false);
        optJson.addProperty("playerName", "KALTURA PLAYER");

        optJson.addProperty("playerVersion", PlayKitManager.VERSION_STRING);

        // Set ContentMetadata for every asset played.
        optJson.addProperty("assetId", "1234");
        optJson.addProperty("assetName", "My IMA Asset");
        optJson.addProperty("videoId", "5678");
        optJson.addProperty("seriesTitle", "Test Series");
        optJson.addProperty("episodeNumber", "1");
        optJson.addProperty("season", "2");
        optJson.addProperty("contentType", "Episode");
        optJson.addProperty("drmProtection", "WideVine");
        optJson.addProperty("genre", "Romance,Horror");

        // Set Application data.
        optJson.addProperty("appName", "KalturaApp");
        optJson.addProperty("appVersion", "v1.0.0");

        // Set metadata for device.
        optJson.addProperty("deviceMarketingName", "Oneplus6");
        optJson.addProperty("videoQuality", "4K-HDR");
        optJson.addProperty("deviceId", "abcd-efgh-ijkl-mnop");
        optJson.addProperty("isDisableManifestFetch", false);

        // Set CustomTags.
        JsonObject optCustomJson = new JsonObject();

        optCustomJson.addProperty("param1", "12345");
        optCustomJson.addProperty("param2", "Sandbox Watch");
        optCustomJson.addProperty("param3", "12345");
        optCustomJson.addProperty("param4", "54321");
        optCustomJson.addProperty("param5", "1_nd547djd");
        optCustomJson.addProperty("householdId", "12345");
        optCustomJson.addProperty("properties", "{'key':'value'}");
        optCustomJson.addProperty("playerStartupTime", "12345");
        optCustomJson.addProperty("username", "123456789");
        optCustomJson.addProperty("seriesId", "123454321");
        
        optJson.addProperty("customTags", optCustomJson.toString() );
        

        return optJson;
    }


```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
    private fun createJson(): JsonObject? {
        val optJson = JsonObject()

        // Main config goes here.
        optJson.addProperty("customerId", "18410666590")
        optJson.addProperty("domainName", "EladDomain")
        optJson.addProperty("subscriberId", "SubscriberId")
        optJson.addProperty("subscriberType", "SubscriberType")
        optJson.addProperty("subscriberTag", "SubscriberTag")
        optJson.addProperty("doHash", false)
        optJson.addProperty("playerName", "KALTURA PLAYER")
        optJson.addProperty("playerVersion", PlayKitManager.VERSION_STRING)

        // Set ContentMetadata for every asset played.
        optJson.addProperty("assetId", "1234")
        optJson.addProperty("assetName", "My IMA Asset")
        optJson.addProperty("videoId", "5678")
        optJson.addProperty("seriesTitle", "Test Series")
        optJson.addProperty("episodeNumber", "1")
        optJson.addProperty("season", "2")
        optJson.addProperty("contentType", "Episode")
        optJson.addProperty("drmProtection", "WideVine")
        optJson.addProperty("genre", "Romance,Horror")

        // Set Application data.
        optJson.addProperty("appName", "KalturaApp")
        optJson.addProperty("appVersion", "v1.0.0")

        // Set metadata for device.
        optJson.addProperty("deviceMarketingName", "Oneplus6")
        optJson.addProperty("videoQuality", "4K-HDR")
        optJson.addProperty("deviceId", "abcd-efgh-ijkl-mnop")
        optJson.addProperty("isDisableManifestFetch", false)

        // Set CustomTags.
        val optCustomJson =  JsonObject()

        optCustomJson.addProperty("param1", "12345")
        optCustomJson.addProperty("param2", "Sandbox Watch")
        optCustomJson.addProperty("param3", "12345")
        optCustomJson.addProperty("param4", "54321")
        optCustomJson.addProperty("param5", "1_nd547djd")
        optCustomJson.addProperty("householdId", "12345")
        optCustomJson.addProperty("properties", "{'key':'value'}")
        optCustomJson.addProperty("playerStartupTime", "12345")
        optCustomJson.addProperty("username", "123456789")
        optCustomJson.addProperty("seriesId", "123454321")
        
        optJson.addProperty("customTags", optCustomJson.toString() )
        
        return optJson
    }
    
    
    private fun createIMADAIPlugin(): PKPluginConfigs {


        //First register your SamplePlugin.
        PlayKitManager.registerPlugins(this, MediamelonPlugin.factory)

        //Initialize plugin configuration object.
        val pluginConfigs = PKPluginConfigs()
    .....
        //Initialize + Configure  IMADAIConfig object
        pluginConfigs.setPluginConfig(IMADAIPlugin.factory.name, daiConfigVodHls2)

        //Set jsonObject to the main pluginConfigs object.
        pluginConfigs.setPluginConfig(MediamelonPlugin.factory.getName(), createJson())

    .....
    }
    
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mediamelon.com/mediamelon/smartsight-player-sdk-integration/android/kaltura-sdk-integration-document.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
