AMP iOS Core Integration Guide

Document created by Herberth Alvarado Champion on May 5, 2017Last modified by Frank Paolino on May 25, 2017
Version 8Show Document
  • View in full screen mode

Maintainers: David Cortes Saenz & Miguel Lopez Valenciano

 

 

Akamai Adaptive Media Player is a media player for iOS and tvOS. Akamai AMP can manage different plugins like Chromecast Playback, Akamai Media Analytics, Playback Statistics, Octoshape, ComScore, and VR.

 

Installation


AmpCore: manage basic playback and functions related to playback like ID3 Tracks, Multi-Language and Closed Caption support.

 

Implementing the Core

To initialize the Core and use basic playback, first make sure to implement the PlayerEventObserver protocol on your View Controller

import UIKit
import AmpCore
class ViewController: UIViewController, PlayerEventObserver {

 

Declare a variable for the AmpPlayer and create the instance on your viewDidLoad function for example.

var ampPlayer: AmpPlayer!

 

override func viewDidLoad() {
super.viewDidLoad()

 

// Instantiate the AmpPlayer
self.ampPlayer = AmpPlayer(parentView: self.view)

 

// Set your respective license
self.ampPlayer.setLicense(license)

 

// Register the current class as observer to receive notifications
self.ampPlayer.registerObserver(self)

 

// Start handling the url
self.ampPlayer.handleUrl(url)
}

 

The previous initializes the player, sets the license, registers the class as an observer and then starts handling the stream, this will not start your playback, there are a couple of ways you can implement autoplay in our player.
The first way is to simply set the autoplay property of the AmpPlayer’s instance to true:

self.ampPlayer.autoplay = true


The other way to accomplish autoplay in our play is to listen to the onBufferingStateChanged in and check for the state BufferingState.ready, then you would proceed to call play in your AmpPlayer instance:

func onBufferingStateChanged(_ ampPlayer: AmpPlayer) {
   if (ampPlayer.bufferingState == BufferingState.ready) {
      // Here we use the manual way to achieve autoplay
      ampPlayer.play()
   }
}

With these simple steps, you are now playing videos with AMP 4.

Attachments

    Outcomes