iOS SDK Setup

1. System Requirements

The THEOplayer iOS SDK can be used from within both Swift and Objective C projects.

2. Getting Started

Using the THEOplayer iOS SDK is possile through the following steps:

  1. In the target's General tab, in the Embedded Binaries click (+) and select the THEOplayerSDK.framework
  2. Import the framework in your view controller
    import THEOplayerSDK
  3. Declare a player variable and initialize it
    var player = THEOplayer()
  4. Position and size your player
    player.frame = CGRect(x: 0, y: 0, width: 320, height: 180)
  5. Add the player to your controller's view hierarchy
    player.addAsSubview(of: controller.view)

3. Controlling the player

Once a player is created and set in your view, you can start interacting with the player instance using the THEOplayer API.

Setting a source

Create a SourceDescription object and set the player's source

let source = SourceDescription(sources: TypedSource(src: "", type: "application/x-mpegurl"))
player.source = source


Add custom CSS and JavaScript

If you want to use custom CSS or JavaScript files you can instantiate the player with a THEOplayerConfiguration object.

let style = Bundle.main.path(forResource:"style", ofType: "css")! 
let script = Bundle.main.path(forResource:"script", ofType: "js")!
let config = THEOplayerConfiguration(chromeless: false, cssPaths:[style], defaultCss: false, jsPaths: [script])
var player = THEOplayer(configuration: config)
CSS and Chromeless

With the chromeless flag you can choose to use the chromeless version of the player which does not contain the THEOplayer UI. This allows you to write your own custom UI.

The THEOplayer css is not loaded when chromeless is enabled.

When chromeless is false, the THEOplayer UI is used. In that case the default style can still be disabled by setting the defaultCss flag to false.

4. Adding support for Chromecast

In order to enable chromecast, a few extra steps need to be taken. These steps are described below.

  1. Upgrade to the latest THEOplayer iOS SDK release (≥ 1.0.3)
  2. To add chromecast support the first thing you need is to include the Cast Framework. The following guide will help you adding the Cast Framework binary.
  3. To enable chromecast on iOS a GCKCastOptions configuration should be specified. This class contains the configuration for chromecast on iOS.
    let options = GCKCastOptions(receiverApplicationID: Chromecast.defaultReceiverApplicationID)
  4. That 's it. When chromecast enabled devices are discovered, the player will display a chromecast button. The player also works nicely together with the Chromecast controls that are part of the Chromecast Framework, (ex. GCKUICastButton).