Chromecast Module for AMP iOS

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

Maintainers: Miguel Lopez Valenciano & David Cortes Saenz



Our Chromecast module augments our core playback SDK, by managing the connection and synchronization between Chromecast devices and AMP.


First, import the AmpChromecast.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. *

Chromecast also has some dependencies, so we must add them as well:

  • MediaPlayer.framework
  • AudioToolbox.framework
  • Accelerate.framework
  • libc++.tbd

Please keep referring to the Chromecast official documentation as their dependencies keep changing.


How to Use

Let’s first import the required frameworks:

import AmpCore
import AmpChromecast
// If you listen to our `AmpChromecastObserver` events, you must import `GoogleCast`
import GoogleCast


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

var ampPlayer: AmpPlayer!
var ampChromecast: AmpChromecastManager!


And it’s time to instantiate them now, in your viewDidLoad function:

// Instantiate player


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


// Register yourself as an observer if required


// Instantiate the Chromecast Manager
self.ampChromecast = AmpChromecastManager(ampPlayer: self.ampPlayer)

// If you want to listen to `AmpChromecastObserver` events, register as an observer




There is just one more step, which is displaying the list of devices so the user can start streaming to it:


As you probably noticed, it is an IBAction, so you just link that action to the UI element that should display the devices menu, such as a button.