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:
- In the target's General tab, in the Embedded Binaries click (+) and select the THEOplayerSDK.framework
- Import the framework in your view controller
- Declare a player variable and initialize it
var player = THEOplayer()
- Position and size your player
player.frame = CGRect(x: 0, y: 0, width: 320, height: 180)
- Add the player to your controller's view hierarchy
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: "https://www.examples.com/index.m3u8", type: "application/x-mpegurl")) player.source = source
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.
- Upgrade to the latest THEOplayer iOS SDK release (≥ 1.0.3)
- 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.
- 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)
- 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).