Techdocs

AMP iOS SDK

AMP player

Freewheel

This module’s goal is to ease the integration Freewheel and the Akamai AMP Player for iOS. With just a few steps we can achieve this integration, let’s see how.

Installation

Let’s first import the required frameworks:

import AmpCore
import AmpFreewheel

Then, let’s add the related variables in our UIViewController:

var ampPlayer: AmpPlayer!
var ampFreewheel: AmpFreewheel!

And its time to instantiate them now, in your viewDidLoad function:
// Instantiate player

self.ampPlayer = AmpPlayer(parentView: self.view)

// Register yourself as an observer if required
self.ampPlayer.registerObserver(self)

self.ampPlayer.setLicense(license)

self.ampFreewheel = AmpFreewheel(ampPlayer: self.ampPlayer!, networkId: networkId, serverUrl: serverUrl)

let videoAssetId = VideoAssetId(id: id, duration: duration)

self.ampFreewheel?.requestAds(profile: profile, siteSectionId: siteSectionId, videoAssetId: videoAssetId) { adController in
    adController.addPrerollSlot("pre1")
    adController.addOverlaySlot("over1", timePosition: 5)
    adController.addMidrollSlot("mid1", timePosition: 10)
    adController.addOverlaySlot("over2", timePosition: 15)
    adController.addPostrollSlot("post1")
 }

self.ampPlayer.play(url: YOUR_VIDEO_URL)

And that’s basically it, with just those few steps, you have a working integration between AMP and Freewheel.