Adaptive Media Player

AmpYoSpace Docs

YoSpace Module for AMP iOS

This module’s goal is to ease the integration of Google Interactive Media Ads and the Akamai AMP Player for iOS. With just some simple steps a few steps we can achieve this integration, let’s see how.

Installation

Just import the AmpYoSpace.framework in your project. For more information check out the AmpCore’s documentation.

*Note: Make sure to add the frameworks as Embedded Binaries or you’ll get an error about a missing image. *

How to Use

Let’s first import the required frameworks:

import AmpCore
import AmpYoSpace

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

    var ampPlayer: AmpPlayer!
    var ampYoSpaceManager: AmpYoSpaceManager!

And it’s 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)

    let properties:YSSessionProperties = YSSessionProperties()
    properties.timeout = 2
    YSSessionProperties.add(.DEBUG_PARSING)

    self.ampYoSpaceManager = AmpYoSpaceManager(yoSpaceUrl, ampPlayer: self.ampPlayer!, yoSpaceProperties: properties, streamType: .Live, observer: self, enableLogs: true)

    self.ampPlayer.handleUrl(url)

You may have noticed that AmpYoSpaceManager needs an observer and we’re giving a reference to the same ViewController, this means that we need to implement the AmpYoSpaceObserver protocol, let’s do that:

extension ViewController : AmpYoSpaceObserver {

    public func contentDidStart(_ playheadPosition: TimeInterval) {

    }

    public func contentDidPause(_ playheadPosition: TimeInterval) {

    }

    public func contentDidResume(_ playheadPosition: TimeInterval) {

    }

    public func contentDidEnd(_ playheadPosition: TimeInterval) {

    }

    public func trackingEventDidOccur(_ event: YSETrackingEvent, for advert: YSAdvert) {

    }

    public func trackingEventDidOccur(_ event: YSETrackingEvent, for nonlinearCreative: YSNonLinearCreative) {

    }

    public func advertBreakDidStart(_ adBreak: YSAdBreak) {

    }

    public func advertBreakDidEnd(_ adBreak: YSAdBreak) {

    }

    public func advertDidStart(_ advert: YSAdvert) {

    }

    public func advertDidEnd(_ advert: YSAdvert) {

    }

}

Those are the callbacks we provide for our YoSpace integration.

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

Need help?

If you need help trying to integrate the player on your project, or you want to report issues or problems you can send a email to amp-sdk-support@akamai.com