Akamai AMP Player for iOS

Akamai AMP player, is a HLS player for iOS and tvOS. Akamai AMP player can manage different plugins like Chromecast Playback, Akamai Media Analytics, Playback Statistics and Octoshape. This guide will cover the iOS process.

Installation

To install the AMP Player on you project you only need to import the main framework:

  • AmpCore.framework

If you need plugins you have to add them too:

  • AmpOctoshape.framework
  • AmpMediaAnalytics.framework
  • AmpStatistics.framework
  • AmpChromecast.framework
  • AmpUICore.framework

and more…

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

How to Use

Using AMP player on your iOS project is very simple, you need to first to declare two variables of type AmpPlayer and AmpPlayerManager:

    var ampPlayer: AmpPlayer!
    var ampPlayerManager: AmpPlayerManager!

Then instantiate both instances in your viewDidLoad() function:

      override func viewDidLoad() {
        super.viewDidLoad()

        self.ampPlayer = AmpPlayer()
        self.ampPlayer.autoplay = true

        self.ampPlayerManager = AmpPlayerManager(ampPlayer: ampPlayer!, parentView: self.view, playerFrame: self.view.frame)

        print("AKAMAI PLAYER VERSION: \(self.ampPlayer!.version)")

        self.ampPlayer?.handleUrl(url)
    }

This will create a player using the controller’s main view as our player view, we also set ampPlayer.autoplay to true, this way you don’t have to use our event system unless you need to.

AMP Player also offers custom callbacks to manage the Playback events and plugin events.

For example if you want to track the Playback events, you need to implement the PlayerEventObserver and register to the manager.

class ViewController: UIViewController, PlayerEventObserver

Now register the the observer on the AmpPlayerManager using the AmpPlayer reference

self.ampPlayer.registerObserver(self)

Finally you can implement the callbacks on your class, we are listeng here when the stream is ready to play, to generate an autoplay feature.

func onAmpBufferingStateChanged(ampPlayer: AmpPlayer) {
  if (ampPlayer.bufferingState == BufferingState.Ready) {
    print("BufferingState.Ready")
    ampPlayer.play()
  }
}

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