Enable Chromecast on the Sender

This article explains how to enable the Chromecast Sender Capabilities on the Web SDK, iOS SDK and Android SDK.

Table of Contents


THEOplayer is built in a modular way, and a THEOplayer library has a set of features enabled (e.g. HLS playback, MPEG-DASH playback, advertisements, etc.).

  1. The Chromecast feature needs to be enabled in your library. Please reach out to your THEOplayer contact to ensure that this feature is enabled.

Import Chromecast SDK


To allow Chromecast playback you need to include Google's Chromecast SDK, which is a JavaScript file. Please check the link below to learn how to include this library:

Once this SDK is imported THEOplayer will automatically add the Chromecast casting capability to your player.

Android SDK

In order to enable chromecast, a few extra steps need and can be taken.

  1. Upgrade THEOplayer: Use a version of THEOplayer’s Android SDK ≥ 1.0.9.
  2. Include the Cast Framework and Media Router libraries

To add chromecast support the first thing you need is to include the Cast Framework and Media Router libraries under the dependencies node in your build.gradle file.

implementation 'com.android.support:mediarouter-v7:25.3.1'
implementation 'com.google.android.gms:play-services-cast-framework:10.2.1'
  1. Set CastOptionsProvider

To enable chromecast on android a CastOptionsProvider should be specified. This class contains the configuration for chromecast on Android. A DefaultCastOptionsProvider is provided as part of the THEOplayer Android SDK. This OptionsProvider associates the THEOplayer chromecast receiver with your sender application. You will need to register this class in your AndroidManifest.xml file within a meta-data tag under your application node.


Optional: Add routing button to your app

In order to get this button to appear in your application's Toolbar, the easiest way is to include it in the menu XML file for your Activity.

  1. In your res folder add a menu folder
  2. Add a activitymainmenu.xml file
  3. Add the following contents to this file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    app:showAsAction="always" />
  1. Initialize this new MenuItem in the onCreateOptionsMenu method of your Activity (Make sure you have an AppCompatActivity).

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main_menu, menu);
            menu, R.id.media_route_menu_item);
        return true;

Optional: Add MiniController to your app

In your main activity xml add the following fragment

        class="com.google.android.gms.cast.framework.media.widget.MiniControllerFragment" />

Optional: Set a CastStrategy to your THEOplayerConfig

THEOplayer Android SDK support Chromecast CastStrategy to define the joining behaviour.

new THEOplayerConfig.Builder()


  • Please not that chromecast support is not available for the Android TV SDK. 
  • For more information please visit this link.

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

  1. Upgrade THEOplayer: Use a version of THEOplayer’s iOS SDK ≥ 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.


Static vs Dynamic Framework: Because the THEOplayer iOS SDK is a Dynamic Framework, it should not include any dependency frameworks on which it relies (e.g. the Chromecast SDK). Instead, developers should include the dependencies on which THEOplayer relies. Therefore, using a Dynamic Framework ensures that there are no symbol clashes. More info can be found in this article: https://medium.com/onfido-tech/reusing-code-and-resources-with-swift-static-libraries-and-resource-bundles-d070e82d3b3d

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

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

def target_pods
  pod 'google-cast-sdk'

target'YourProjectTarget' do
    # Select one of the chromecast versions
    pod 'google-cast-sdk', '4.3.0'

Manual setup

Download the Dynamic Cast Framework from the google developer website. Libraries 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.

  1. Set GCKCastContext

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

let options = GCKCastOptions(receiverApplicationID: "A1B2C3D4")

or use the default THEOplayer cast options.


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).

Chromecast Receiver app


By default THEOplayer's receiver app will be used. If you have your own receiver app than you can overwrite this by adjusting the PlayerConfiguration's cast property.

Android SDK

If you need custom settings for your Chromecast integration (e.g. a custom receiver id) you can create your own CastOptionsProvider by subclassing com.google.android.gms.cast.framework.OptionsProvider and implementing the getCastOptions method.

public CastOptions getCastOptions(Context context) {
        return new CastOptions.Builder()

By default THEOplayer’s receiver app will be set when you set THEOplayerCastHelper.setGCKCastContextSharedInstanceWithDefaultCastOptions(). A custom receiver app can be configured through GCKCastContext.setSharedInstanceWith(GCKCastOptions(receiverApplicationID: "A1B2C3D4"))

Make sure to follow us on GitHub!
Copyright © 2020. All Rights Reserved.
New York