Sample code

Import the Google Cast integration module

import THEOplayerGoogleCastIntegration

Create and add a Google Cast integration to your THEOplayer

As of v8.14.0, the integration will be automatically created and added to THEOplayer when you add the THEOplayerGoogleCastIntegration package to your project. It is still possible to create and add an integration to override the auto-integration:

let castIntegration: Integration = GoogleCastIntegrationFactory.createIntegration(on: theoplayer, with: .init(strategy: .auto))
theoplayer.addIntegration(castIntegration)

Setup the Google Cast context

Skip this step in case a customized context configuration is required.

THEOplayer provides a default context, which will use a CAF v3 receiver application to cast to. Preferrably this method should be called early in the lifecycle of the application, such as in the AppDelegate’s didFinishLaunchingWithOptions method:

CastIntegrationHelper.setGCKCastContextSharedInstanceWithDefaultCastOptions()

Sample Code

For a more comprehensive implementation, refer to the sample app found here: https://github.com/THEOplayer/samples-ios-sdk/tree/master/Google-Cast