> 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/ios/theoplayer-xcframework.md).

# THEOPlayer XCFramework

### **Steps Involved in Integrating the MMTheoPlayerFramework**&#x20;

There are four steps involved in integrating the SmartSight Player SDK

1. Importing the framework
2. Providing asset information for the content before starting the player and after creating its instance
3. Cleaning up the SDK integration session
4. Disable manifest-fetching by the SDK

#### **1. Import Frameworks**

```cpp
import THEOplayerSDK
//Integration Step 1
import MMTheoplayerFramework
```

#### 2. Provide asset information

2a) Add the following method to integrate the MediaMelon Player SDK to the class `ViewController`

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

```cpp
 class ViewController: UIViewController {
    var theoplayer: THEOplayer!
    var assetInfo:MMAssetInformation!
    
    //Integration step 2a
    func integrateMMSDK(){
        TheoPlayerIntegrationWrapper.shared.enableLogTrace(logStTrace: true) //Send false to disable log trace
        
        let regInfo = MMRegistrationInformation(customerID: "CUSTOMER_ID", playerName:"PLAYER_NAME")
        regInfo.setPlayerInformation(brand: "PLAYER_BRAND", model: "PLAYER_MODEL", version: "PLAYER_VERSION")
        regInfo.setSubscriberInformation(subscriberID: "SUBSCRIBER_ID", subscriberType: "SUBSCRIBER_TYPE", subscriberTag: "SUBSCRIBER_TAG")
        TheoPlayerIntegrationWrapper.setPlayerRegistrationInformation(registrationInformation: regInfo, player: theoplayer)
    }
```

{% hint style="info" %}
Call to `setPlayerRegistrationInformation` is mandatory.
{% endhint %}

2b) Call the method integrateMMSDK after setting up the player

```cpp
override func viewDidLoad() {
      super.viewDidLoad()
      setupTheoPlayer()
      //Integration Step 2b
      integrateMMSDK()
      theoplayer.source = sampleSource
}
```

2c) Create and Set the Asset Information

The application may like to set the auxiliary information of the asset so that it can be recorded in Smartsight. This information could be assetId, assetName, videoId (describing the title to which assets belong), custom metadata, etc. Call to `addCustomKVP` is optional. However, when a call is made, setting both the custom key and the value is mandatory

```swift
let assetInfo = MMAssetInformation(assetURL: "ASSET_URL", assetID: "ASSET_ID", assetName: "ASSET_NAME", videoId: "VIDEO_ID")
   assetInfo.setEpisodeNumber("EPISODE_NUMBER")
   assetInfo.setContentType("CONTENT_TYPE")
   assetInfo.setSeriesTitle("SERIES_TITLE")
   assetInfo.setGenre("GENRE")
   assetInfo.setSeason("SEASON")
   assetInfo.setDrmProtection("DRM_PROTECTION")
   assetInfo.addCustomKVP("CUSTOM_KEY_1", "CUSTOM_VALUE_1")
   assetInfo.addCustomKVP("CUSTOM_KEY_2", "CUSTOM_VALUE_2")
        
     let encodedAssetInfo = try? JSONEncoder().encode(assetInfo)
     var jsonAssetInfo = ""
     if let encodedAssetInfo = encodedAssetInfo{
         jsonAssetInfo = String(data: encodedAssetInfo, encoding: .utf8) ?? ""
}
```

2d) Adding Custom parameters.&#x20;

The app can produce this asset information to the SmartSight Player SDK by utilizing the metadata field of the `SourceDescription` used by the Theo player.

```cpp
return SourceDescription(
         source: TypedSource(
             src: "https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8",
             type: "application/x-mpegurl"
         ),
         //Integration Step 2d
         metadata : MetadataDescription(metadataKeys: [TheoMMIntegration.KAssetInformationKey:jsonAssetInfo])
 )
```

#### 3) Cleanup of session

When the view controller used for playback is removed, call the cleanUp method of the SmartSight Player SDK and add the following method in class `ViewController`

```cpp
 deinit{
     TheoPlayerIntegrationWrapper.cleanUp()
 }
```

#### 4) Disable Manifest

{% hint style="info" %}
&#x20;Disable Manifest Fetch is optional
{% endhint %}

&#x20;If your workflow restricts the manifest to be accessible from both the player and the MediaMelon Player SDK simultaneously, then, you can disable the fetch of the manifest via `disableManifestsFetch` in method `integrateMMSDK()`

```cpp
 func integrateMMSDK(){
     .
     .
     .
     .
     TheoPlayerIntegrationWrapper.setPlayerRegistrationInformation(registrationInformation: regInfo, player: theoplayer)
     TheoPlayerIntegrationWrapper.disableManifestsFetch(disable: true)
 }
```

| **Variable**     | **Description**                                                                                                                                                                      |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| PLAYER\_NAME     | String containing the Player Name.                                                                                                                                                   |
| CUSTOMER\_ID     | String containing your MediaMelon-assigned Customer ID.                                                                                                                              |
| SUBSCRIBER\_ID   | String containing your Subscriber’s ID. If you do not use subscriber IDs, enter null                                                                                                 |
| DOMAIN\_NAME     | String containing your section of your subscriber or assets. (Optional)                                                                                                              |
| SUBSCRIBER\_TYPE | String containing the Subscriber Type (e.g. “Free”, “Paid”). If you do not use subscriber types, enter null                                                                          |
| SUBSCRIBER\_TAG  | String containing an additional subscriber-specific information. This is sent in clear (not hashed) to SmartSight and it is advised to not send sensitive information in this field. |
| ASSET\_ID        | String containing Asset Id.                                                                                                                                                          |
| ASSET\_NAME      | String containing Asset Name.                                                                                                                                                        |
| VIDEO\_ID        | String containing your video’s ID. If you do not use videos IDs, enter null.                                                                                                         |
| CONTENT\_TYPE    | String containing type of the Content. For example - "Movie", "Special", "Clip", "Scene Epis Lifts".                                                                                 |
| GENRE            | String containing Genre of the content. For example - "Comedy", "Horror".                                                                                                            |
| DRM\_PROTECTION  | Widevine, Fairplay, Playready etc. Unknown means content is protected, but protection type is unknown. For clear contents, do not set this field                                     |
| EPISODE\_NUMBER  | String containing sequence number of the Episode.                                                                                                                                    |
| SEASON           | String containing the Season. For example - "Season1".                                                                                                                               |
| SERIES\_TITLE    | String containing Title of the Series.                                                                                                                                               |
| PLAYER\_BRAND    | String containing Player Brand.                                                                                                                                                      |
| PLAYER\_MODEL    | String containing Player Model. For example - This could be a variant of player. Say name of third party player used by organisation. Or any human readable name of the player.      |
| PLAYER\_VERSION  | String containing Player Version.                                                                                                                                                    |
