Akamai AMP Player for iOS

Document created by Herberth Alvarado Employee on May 15, 2017Last modified by Herberth Alvarado Employee on May 15, 2017
Version 6Show Document
  • View in full screen mode

Maintainers: Miguel Lopez Valenciano & David Cortes Saenz

 

 

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, first, you need to a variable of type AmpPlayer:

var ampPlayer: AmpPlayer!

Then instantiate both instances in your viewDidLoad() function:

override func viewDidLoad() {
   super.viewDidLoad()

   self
.ampPlayer = AmpPlayer(parentView: self.view)
   self.ampPlayer.autoplay = true
   
self.ampPlayer.setLicense(license)

   
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 AmpPlayer instance.

self.ampPlayer.registerObserver(self)

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

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

Attachments

    Outcomes