AV Player with Nowtilus SSAI (old)

Step by step integration of the Mediamelon Player SDK with Nowtilus SSAI with native Apple AV Player on iOS

Step 0: Creating AV Player based media player application

Create a directory for integration by doing the following. Open the terminal, change directory to the home directory, and create a folder sampleintegration

cd ~/
mkdir sampleintegration
cd sampleintegration/

Pull the Sample Application from https://sdk.mediamelon.com/$CustomerID/iOS/AVPlayer_SampleApplication.zip and unzip it

wget https://sdk.mediamelon.com/$CustomerID/iOS/AVPlayer_SampleApplication.zips

Step 1: Get the MMGenericFramework Static Framework Library

Download the MMGenericFramework static faremwork

Copy the MMGenericFramework static framework to the AVPlayerWithNowtilusSSAi directory

If you are building for the simulator use the MMGenericFramework.framework in the iphonesimulator-x86 and which building for the device use the MMGenericFramework.framework in the iphoneos-arm64 directory

Step 2: Integrating the MMGeneric Framework with the AV Player Sample Application

There are five steps involved for integrating the MediaMelon Player SDK using the MediaMelonSmartStreaming Framework:

  1. Add the appropriate MMGenericFramework to the AV Player Sample Application

  2. Providing asset information for the content before starting the player and after creating its instance

  3. Disable manifest fetching by the SDK

  4. Initializing SSAI

  5. Cleaning up the SDK integration session

All AV Player related code of the sample application can be found in the Swift classViewController.swift

1. Import Frameworks

import MMGenericFramework

2. Provide Asset information

After the instance of the player is create, we should set the asset information and send it to before starting its playback. In ViewController.swift, call function self.configureMMSDKwithURL(mediaURL: String, vastURL: String, player: AVPlayer)

private func configureMMSDKWithURL(urlStr: String, vastURLStr: String, player: AVPlayer) {
        print("Integrating with \(String(describing: AVPlayerIntegrationWrapper.getVersion()))")
        let assetInfo = MMAssetInformation(assetURL: urlStr, assetID: String(arc4random()), assetName: "assetNameRandom", videoId: "VIDEO_ID")
        assetInfo.addCustomKVP("CustomKVP1Key", "CustomKVP1Value")
            assetInfo.addCustomKVP("CustomKVP2Key", "CustomKVP2Value")
            assetInfo.setQBRMode(.QBRModeDisabled, withMetaURL: nil)
        let registrationInfo = MMRegistrationInformation(customerID: "202290422", playerName: "AVPLayer")
        registrationInfo.setPlayerInformation(brand: "Apple", model: "iPhone 11", version: "14.1")
        registrationInfo.setSubscriberInformation(subscriberID: "<subscriber_id>", subscriberType: "<subscriber_type>", subscriberTag: "TAGIT")
        AVPlayerIntegrationWrapper.shared.mmssaiManagerDelegate = self
        AVPlayerIntegrationWrapper.disableManifestsFetch(disable: true)
        AVPlayerIntegrationWrapper.initializeAssetForPlayer(assetInfo: assetInfo, registrationInformation: registrationInfo, player: player)
        //Initialize SSAI
        AVPlayerIntegrationWrapper.shared.initialiseSSAIAdManager(mediaUrl: self.mediaURL, vastUrl: self.vastURL, isLive: self.isLive)
 }

3. Cleaning up the SDK Session

We need to clean up the SDK session once the playback completes. The SDK internally manages the cleanup for most of the cases. For example - when playback finishes, or some error is notified.

However, in some error cases, like network reachability issues, the error notification is delayed. And before this error notification is available, the user may trigger another session. Therefore, it is advised to clean up the session once the playback finishes.

We recommend cleanup at the following two places.

  • When the view controller hosting the post roll ad terminates

  • When the player is restarted

AVPlayerIntegrationWrapper.shared.stopSSAIAdManager()
AVPlayerIntegrationWrapper.cleanUp()

5. Disable manifest fetching by the SDK

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

private func configureMMSDKWithURL(mediaURL: String, vastURL: String) {
    .
    .
    .
    AVPlayerIntegrationWrapper.cleanUp()
    AVPlayerIntegrationIntegrationWrapper.disableManifestsFetch(disable: true)
    AVPlayerIntegrationIntegrationWrapper.initializeAssetForPlayer(assetInfo: assetInfo, registrationInformation: registrationInfo, player: player)
}

Note: Disable Manifest Fetch is Optional

5. Add the MMSSAIManagerDelegate

Add the MMSSAIManagerDelegate the ViewController class in ViewController.swift. This delegate will be used for receiving Ad related events and data. At every Ad event the Delegate will fire the notifyMMSSAIAdEventsWith function. This can be used to display Ad related data, enable or disable Ad skipping etc.

class ViewController: UIViewController, MMSSAIManagerDelegate 
.....
    func notifyMMSSAIAdEventsWith(eventName: MMSSAIAdSate, adInfo: MMSSAIAdDetails) {
        
            print("---------------------------------------------------")
            print(" Ad Id :",adInfo.adId )
            print(" Ad Title :",adInfo.adTitle )
            print(" Ad Server :",adInfo.adServer )
            print(" Ad Duration :",adInfo.adDuration )
            print(" Ad Position :",adInfo.position )
            print(" Ad Event :",eventName )
            print("---------------------------------------------------")
    }

6. Initialize the SSAI Ad Manager

Initialize the SSAI Ad Manager to track the Ads and report Ad related metric. For live stream the last parameter isLive is set to true.

private func configureMMSDKWithURL(mediaURL: String, vastURL: String) {
    .
    .
    .
     
        AVPlayerIntegrationWrapper.shared.initialiseSSAIAdManager(mediaUrl: mediaURL, vastUrl: vastURL, isLive: true)
}

7. Stop the SSAI Ad Manager

To stop the SSAI Ad Manager call the following API


AVPlayerIntegrationWrapper.shared.stopSSAIAdManager()

Step 3: Adding multiple static frameworks including the MMGeneric (Static) Framework

libtool -static -o MyToplevelSDK.framework MMGeneric.framework/MMGenericFramework AnotherSDK.framework/AnotherSDK

Last updated