IntroductionHow to update an SDK?THEOplayer 5.0 - Native Mobile iOS/tvOS and Android SDKs
Getting started on Web (Extended)Getting started with the new Web UIGetting started on WebAPI examplesHow to implement Keyboard HotkeysHow to embed an iframeHow to implement a seamless transition between videos?How can I use video inside THEOplayer?How to work around browser cache with a new license?How to customise quality selection & labels (MP4)How to get frame-accurate currentTime display in the UI Control barHow to play an LCEVC source with THEOplayerHow to use WebXR with THEOplayer
Android legacy (4.12.x)
Getting started on Legacy Android SDK (4.12.x)Legacy Android SDK (4.12.x) customizationHow to couple the native MediaRouteButton to THEOplayerHow to enable -experimental- native rendering on AndroidHow to do offline Playback with AES-128 Encrypted Streams on Android
Getting started with the Android UIGetting started on AndroidAndroid Feature IntegrationsMigration from THEOplayer Android/AndroidTV/FireTV SDK 4.x to THEOplayer Android SDK 5.0
iOS legacy (4.12.x)
Getting started on iOSiOS/tvOS SDK and Legacy iOS/tvOS SDK (4.12.x) CustomizationMy app does not want to build for the app storeHow to bypass copy() not working in Safari consoleHow to couple the native GCKUICastButton to THEOplayeriOS/tvOS SDK and Legacy iOS/tvOS SDK (4.12.x) Touch-events (gestures)Building for iOS Simulator, but the linked and embedded framework THEOplayerSDK.framework was built for iOS + iOS SimulatorHow to implement custom local network access (LNA) interstitial dialog for Chromecast
Getting started guide for THEOplayer iOS/tvOS SDK 5.0THEOplayer iOS/tvOS 5.0 Feature IntegrationsMigration from THEOplayer iOS and tvOS SDK 4.x to THEOplayer iOS/tvOS SDK 5.0
Android TV Legacy (4.12.x)
Getting started on Android TV Legacy (4.12.x)
Getting started on tvOS
Getting started on ChromecastChromecast Application Customization
Getting Started on webOS
Getting started on TizenInstalling the Tizen developer toolsSetting up a Tizen device for debuggingDeploying a test app on a physical Tizen deviceDeploying a test app on a Tizen emulator
Getting Started on Roku
Fire TV Legacy (4.12.x)
Getting started on Fire TV Legacy (4.12.x)

How to couple the native GCKUICastButton to THEOplayer

This page shows how to wire up iOS's native GCKUICastButton to THEOplayer. Your native button will be provided with the following behavior:

  • Clicking the button while disconnected will start a Chromecast session. The currently set source will start playing.
  • Clicking the button while casting will stop the current session. The player will be paused.


  • Create a GCKUICastButton
  • Override the behavior of this button

Step-by-step guide

You can modify the behavior of the GCKUICastButton by disabling triggering the default cast dialog and adding a new target for the button. Below, we provide an example implementation which uses the Cast API of a previously created THEOplayer.

override func viewDidLoad() {
    self.theoplayer = THEOplayer()
    self.castButton = GCKUICastButton(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(24), height: CGFloat(24)))
    self.castButton.triggersDefaultCastDialog = false
    self.castButton.addTarget(self, action: #selector(handleCastButtonTap), for: UIControlEvents.touchUpInside)    
@objc func handleCastButtonTap() {
    guard let chromecast = self.theoplayer.cast?.chromecast else {
    if chromecast.state == PlayerCastState.available {
    } else if chromecast.state == PlayerCastState.connected || chromecast.state == PlayerCastState.connecting {
Make sure to follow us on GitHub!
Copyright © 2022. All Rights Reserved.
New York