iOS SDK Chromecast

Adding support for Chromecast

In order to enable Chromecast, a few extra steps need to be taken:

  1. Upgrade to the latest THEOplayer iOS SDK release (≥ 1.0.3)
  2. Setup the Cast Framework:

iOS 13 Warning: Apple permissions changes to iOS 13 and Xcode 11 have impacted the Google Cast iOS SDK in a number of ways. Please see the iOS 13 Changes document to see how your app will be impacted.

iOS 12 Warning: If developing using Xcode 10 and targeting iOS devices running iOS 12 or higher, the "Access WiFi Information" capability is required in order to discover and connect to Cast devices.

https://developers.google.com/cast/docs/ios_sender_setup
  • Cocoapods setup:

Supported until version '4.3.0', pending further investigation for versions above '4.3.0'.

# Comment the next line if you are not using Swift and do not want to use dynamic frameworks
use_frameworks
!

# Uncomment the next line to define a global platform for your project
# platform
:ios, '9.0'

def target_pods
  pod
'google-cast-sdk'
end

target'YourProjectTarget'
do
# Select one of the chromecast versions
pod 'google-cast-sdk', '4.3.0'
end
  • Manual setup:

Download the Dynamic Cast Framework from the google developer websiteLibraries without guest mode have been provided for situations where your app does not require the feature or you do not wish to require Bluetooth® permissions, which have been introduced in iOS 13. Please see the iOS 13 Changes document for more information.

3. To enable Chromecast on iOS the GCKCastContext shared instance should be set with a GCKCastOptions.

let options = GCKCastOptions(receiverApplicationID: "A1B2C3D4")
GCKCastContext.setSharedInstanceWith(options)

or use the default THEOplayer cast options.

THEOplayerCastHelper.setGCKCastContextSharedInstanceWithDefaultCastOptions()

 

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, (e.g. GCKUICastButton or the mini controller).