<img src="https://img.shields.io/badge/%20-ENTERPRISE-%23B10031" style="float:left"/><br /> <img src="https://img.shields.io/badge/Android-V4-009727?logo=android" 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 <b>build.gradle</b> 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 <b>Gradle</b>.



### Manually add the .aar dependency

  1. In Android Studio, open your app.

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

  3. Click <b>Next</b>.

  4. Select <b>jwplayer-chromecast:4.x.x.aar</b> from your computer.

  5. Click <b>Finish</b>.

  6. Click <b>File > Project Structure... > Modules > App > Dependencies</b>.

  7. Click the plus sign in the main panel.

  8. Select <b>Module dependency</b>.

  9. Select <b>jwplayer-chromecast:4.x.x</b>.

  10. Click <b>OK</b>.

  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.<br /> 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.<br /> 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.


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



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 />

(Script tags will be stripped)