<img src="https://img.shields.io/badge/%20-ENTERPRISE-%23B10031" style="float:left"/><br />

The Google Cast framework enables a viewer to stream video and audio content to a compatible TV or sound system. By including the Google Cast framework in your app, a viewer can use a cast button to stream your content to a Chromecast-enabled device on a shared network connection.



  • The JWP SDK supports casting to the Default Media Receiver and to Styled Media Receivers.

  • Custom receivers are not officially supported. However, if the video playback implements the same interface used in the Default Media Receiver, you may be able to initiate a casting session with a custom receiver.

  • To specify a receiver, specify a media receiver app ID when initializing the CastManager.

<br />

The following sections explain how to enable the Google Cast framework for your Android app:

  • Add SDK dependencies for Google Cast

  • Configure your app for Google Cast

After completing the steps in each section, a viewer will be able to begin a casting session from your app.

<br /> <hr />

## Add SDK dependency for Google Cast

To use the Google Cast framework, you must add a dependency to your app. You can use Maven or manually add the dependency.

### Use Maven

  1. In Android Studio, open the **build.gradle** file for your app.

  2. Add the `com.jwplayer:jwplayer-chromecast:4.x.x` dependency.

    Be sure the version number of the module (`x.x.x`) matches the version number you use for the `jwplayer-core` and `jwplayer-common` dependencies.

    
  3. Sync **Gradle**.

<br /><br />

### Manually add the .aar dependency

  1. In Android Studio, open your app.

  2. Click **File > New > New Module... > Import .JAR / .AAR Package**.

  3. Click **Next**.

  4. Select **jwplayer-chromecast:4.x.x.aar** from your computer.

  5. Click **Finish**.

  6. Click **File > Project Structure... > Modules > App > Dependencies**.

  7. Click the plus sign in the main panel.

  8. Select **Module dependency**.

  9. Select **jwplayer-chromecast:4.x.x**.

  10. Click **OK**.

  11. Include the Google Cast SDK in your app's **build.gradle** file.

    

<br /> <hr />

## Configure your app for Google Cast

Now that you have added the Google Cast dependency, you must configure your app:

  1. Implement the `OptionsProvider` interface. This interface supplies options needed to initialize `CastContext`. `CastContext` is a global singleton object that coordinates all interactions of the framework.

    This interface creates an instance of <a href="https://developers.google.com/android/reference/com/google/android/gms/cast/LaunchOptions" target="_blank">LaunchOptions</a> that defines how the receiver application is launched. For example, `setLanguage()` allows you to set the language to be used by the receiver application.

    This interface also creates an instance of <a href="https://developers.google.com/android/reference/com/google/android/gms/cast/framework/CastOptions.Builder" target="_blank">CastOptions</a> that defines the behavior of the framework. For example, `setReceiverApplicationId()` allows you to filter discovery results and to launch the receiver app when a cast session starts.

    
  2. In the <strong>AndroidManifest.xml</strong> of the sender app, use a `<meta-data/>` element to declare the fully-qualified name of the implemented `OptionsProvider`.

    

<br /><br />

Now that you have enabled the Google Cast framework for your Android app, a viewer can now begin casting from your app.

<br /> <hr />

## FAQs

<details><summary><strong>Which features are not supported when casting with an Android SDK player?</strong></summary>

<br />

The following features are not supported during a casting session with an Android SDK player:

  • Advertising

  • Multiple-audio tracks or AudioTrack switching

  • Multiple qualities or quality switching

  • 608/708 captions

  • DVR and live streaming capabilities

<br />

</details>

<details><summary><strong>Can the Chromecast dialog be customized?</strong></summary>

<br />

To customize the appearance of the `VideoMediaRouteControllerDialog` which appears after clicking the `MediaRouteButton`, override the **custom_media_route_controller_controls_dialog.xml** layout file.

As an example, here is the **custom_media_route_controller_controls_dialog.xml** that use in the JWP demo app:



<br />

</details>

<br />

<!-- Removes the automatic page-to-page navigation at the bottom of the page -->

<style> .rm-Pagination { display: none; } </style>