# MediaMelon React Player SDK with IMA

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

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

**Step 3:** [Import Packages](#step-3-import-packages)

**Step 4:** [Register and Initialise SDK](#step-3-initialize-session-and-report-user-intent-to-playback)

**Step 5:** [Report Ad Information](#step-5-report-a-d-information)

**Step 6:** [Report Ad Events](#step-6-report-a-d-events)

**Step 7:** [MMAdState](#step-7-mmadstate)

**Step 8:** [Variables and Description](#step-8-variables-and-description)

### Step 1: Prerequisites

* React Player Application.
* MediaMelon SmartSight SDK `mmsmartstreaming_reactplayer.min.js`   file is necessary.

### Step 2: Set up the build environment

**Using NPM:**

```bash
npm i mediamelon-react-sdk
```

### Step 3: Import Packages

**Using NPM:**

```javascript
import {MMReactPlayerSDK, MMIMAAdapter, MMAdState, MMAdInfo} from 'mediamelon-react-sdk';
```

**Using JS file:**&#x20;

```javascript
import {MMReactPlayerSDK, MMIMAAdapter, MMAdState, MMAdInfo} from './mmsmartstreaming_reactplayer.min.js'
```

### Step 4: Register and Initialise SDK <a href="#step-3-initialize-session-and-report-user-intent-to-playback" id="step-3-initialize-session-and-report-user-intent-to-playback"></a>

The SDK must be initialised at the start of each video session. Initialisation includes setting the application context, initialising the playback session, and indicating the intent for playback with the SDK.

{% hint style="info" %}
The `enableLogTrace` feature should be enabled for testing during the integration process. Set this to False before releasing the player to production.
{% endhint %}

{% hint style="info" %}
CUSTOMER\_ID is your MediaMelon assigned Customer ID. If you do not know your Customer ID contact MediaMelon at <customer-support@mediamelon.com>.
{% endhint %}

Wrap your `Video` component with the `MMReactPlayerSDK`.

```javascript
const MMReactPlayerSDK = MMReactPlayerSDK(ReactPlayer);

<MMReactPlayerSDK
  ref={this.ref}
  playerRef={this.player}
  className='react-player'
  width='100%'
  height='100%'
  url={url}
  ...
  mmOptions={{
    register: {
      customerId: 'CUSTOMER_ID',      
      subscriberId: 'SUBSCRIBER_ID',   
      subscriberType: 'SUBSCRIBER_TYPE',
      subscriberTag:'SUBSCRIBER_TAG',  
      playerName: 'PLAYER_NAME',
      playerBrand:"PLAYER_BRAND",
      playerModel:"PLAYER_MODEL",
      playerVersion:'PLAYER_VERSION',
      basePlayerName: "BASE_PLAYER_NAME",
      basePlayerVersion: "BASE_PLAYER_VERSION",
      experimentName: "EXPERIMENT_NAME",
      subPropertyId: "SUB_PROPERTY_ID",
      viewSessionId: "VIEW_SESSION_ID",
      domainName: 'DOMAIN_NAME',
      applicationName: 'APP_NAME',            
      applicationVersion: 'APP_VERSION',      
      deviceMarketingName:'DEVICE_MARKETING_NAME'
    },
    contentMetadata: {
      assetName:'ASSET_NAME',
      assetId:"ASSET_ID",
      videoId:"VIDEO_ID",
      contentType:'CONTENT_TYPE',
      genre:'GENRE',
      drmProtection:'DRM_PROTECTION',
      episodeNumber:'EPISODE_NUMBER',
      season:'SEASON',
      seriesTitle:'SERIES_TITLE',                  
      isLive: false,
    },
    customTags:{
      "KEY1": "VALUE_STRING1",
      "KEY2": "VALUE_STRING2"
    },
    enableLogTrace:false
  }}
/>
```

### Step 5: Report Ad Information

```javascript
const mmAdAdapter = MMIMAAdapter();

const sdkAdInfo = MMAdInfo();
sdkAdInfo.adClient = "AD_CLIENT";
sdkAdInfo.adId = "AD_ID";
sdkAdInfo.adCreativeId = "CREATIVE_ID";
sdkAdInfo.adUrl = "AD_URL";
sdkAdInfo.adTitle = "AD_TITLE";
sdkAdInfo.adServer = "AD_SERVER";
sdkAdInfo.adCreativeType = "AD_CREATIVE_TYPE";
sdkAdInfo.adDuration = <ad_duration_in_seconds>;
sdkAdInfo.adPodLength = <ad_pod_length>;
sdkAdInfo.adIsLinear = <is_ad_linear_boolean>;

mmAdAdapter.reportAdInfo(sdkAdInfo);
```

### Step 6: Report Ad Events

```javascript
mmAdAdapter.reportAdEvent(<MMAdState>);
```

### Step 7: MMAdState

MMAdState Enum has the following fields:

* AD\_REQUEST
* AD\_IMPRESSION
* AD\_PLAY
* AD\_PLAYING
* AD\_MIDPOINT
* AD\_FIRST\_QUARTILE
* AD\_THIRD\_QUARTILE
* AD\_CLICKED
* AD\_PAUSED
* AD\_RESUMED
* AD\_SKIPPED
* AD\_ENDED
* AD\_COMPLETED
* AD\_ERROR
* AD\_BLOCKED
* AD\_BUFFERING


---

# Agent Instructions: 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:

```
GET https://docs.mediamelon.com/mediamelon/smartsight-player-sdk-integration/web/mediamelon-react-player-sdk-with-ima.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
