Understanding Google Cast and How to Cast-enable a Video App on Android

Javed Ali Mar 24th, 2023

Launched in 2013, Google Chromecast is a popular media streaming device that offers several benefits for both enterprises and end-users. Firstly, it allows for seamless video streaming from OTT (over-the-top) platforms, making it easier for users to access and enjoy their favorite content on the big screen. Additionally, it offers compatibility with both Android and iOS operating systems, making it accessible to a wider range of users. Well, this isn’t done here!

For enterprises, Chromecast can be used for video conferencing and collaboration, providing employees with a simple and effective solution for remote work and team meetings. This helps to increase productivity and streamline communication, while also providing an immersive viewing experience. Moreover, Chromecast supports wireless connectivity, eliminating the need for messy and cluttered cables, and it is easy to set up and use. This makes it an attractive option for end-users who are looking for a hassle-free way to access their favorite content on their television. Overall, Chromecast offers a convenient and cost-effective solution for both enterprise and end-users, allowing for effortless video streaming and a superior viewing experience.

Streaming Content on Chromecast: How to do it?

Google Chromecast is indeed an excellent device for anyone who loves to stream content from their phone, tablet, or laptop. It’s simple and user-friendly interface, combined with its wide range of compatibility, make it a popular choice for both personal and professional use. With Chromecast, users can easily and seamlessly stream their favorite movies, TV shows, music, and other multimedia content directly from their mobile devices onto a larger screen, creating an immersive viewing experience. Whether for entertainment, presentations, or training, Chromecast provides a convenient and cost-effective solution for all your streaming needs.

In addition, Chromecast provides a platform for users to access multiple online streaming services such as Netflix, Hulu, and Disney+. This offers a one-stop shop for all your entertainment needs, making it easier to find and watch the content you love.

Here’s what you will need to enable Chromecast on Android Application-

  1. The latest Android SDK.
  2. Android Studio version 3.2+
  3. One mobile device with Android 4.1+ Jelly Bean (API level 16).
  4. A USB data cable to connect your mobile device to your development computer.
  5. A Google Cast device such as a Chromecast or Android TV configured with internet access.
  6. A TV or monitor with HDMI input.
  7. A Chromecast with Google TV is usually required to test the Cast Connect integration.

About Cast-enabled Application

A Cast-enabled application highlights the Cast button in each of its video activities. Clicking on the Cast button displays a list of Cast devices that a user can select. If the user was playing content locally on the sender device, selecting a Cast device starts or resumes playback on that Cast device. During a Cast session, if any point user wants to stop casting, click on the Cast button and stop casting your application to the Cast device. The user must be able to connect to or disconnect from the Cast device while in any activity of your application, as described in the Google Cast Design Checklist.

top ott platform

How to Cast-enable a video app using the Cast SDK widgets on Android


Update the app build.gradle file to include the necessary library dependencies:

all ott platforms in one app

Sync the project to confirm the project builds without errors.


Add the following new CastOptionsProvider.kt file to the com.google.sample.cast.refplayer package of the project:

best vod

Cast button

Now that the CastContext is initialized, we need to add the Cast button to allow the user to select a Cast device. The Cast button is implemented by the MediaRouteButton from the MediaRouter support library. Like any action icon that you can add to your activity (using either an ActionBar or a Toolbar), you first need to add the corresponding menu item to your menu.

Edit the res/menu/browse.xml file and add the MediaRouteActionProvider item in the menu before the settings item:

ott platform in usa

Override the onCreateOptionsMenu() method of VideoBrowserActivity by using CastButtonFactory to wire up the MediaRouteButton to the Cast framework:

ott platforms in usa

Casting media

At a high level, if you want to play a media on a Cast device, you need to do these things:

The sample app LocalPlayerActivity already distinguishes between local vs remote playback by using this enum:

ott sports platform

The Cast SDK provides a custom view, MiniControllerFragment, which can be added to the app layout file of the activities in which you want to show the mini controller.

ott sports platforms

Add the following fragment definition to the bottom of both res/layout/player_activity.xml and res/layout/video_browser.xml:

ott video streaming

The Google Cast design checklist requires a sender app to implement media controls from a notification and the lock screen.

Media Notification

The Cast SDK provides a MediaNotificationService to help the sender app build media controls for the notification and lock screen. The service is automatically merged into your app’s manifest by gradle.

video content platforms best vod platform

Edit the CastOptionsProvider and change the getCastOptions implementation to match this code:

ott service provider

The Google Cast design checklist requires a sender app to introduce the Cast button to existing users to let them know that the sender app now supports casting and also helps users new to Google Cast.


The Cast SDK provides a custom view, IntroductoryOverlay, that can be used to highlight the Cast button when it is first shown to users. Add the following code to VideoBrowserActivity:

ott streaming platform

The Google Cast design checklist requires a sender app to provide an expanded controller for the media being cast. The expanded controller is a full-screen version of the mini controller.

Expand Controller

The Cast SDK provides a widget for the expanded controller called ExpandedControllerActivity. This is an abstract class you have to subclass to add a Cast button.

Firstly, create a new menu resource file, called expanded_controller.xml, for the expanded controller to provide the Cast button:

premium video on demand

Create a new package expandedcontrols in the com.google.sample.cast.refplayer package. Next, create a new file called ExpandedControlsActivity.kt in the com.google.sample.cast.refplayer.expandedcontrols package.

commercial streaming services

Update the LocalPlayerActivity loadRemoteMedia method to display the ExpandedControlsActivity when the remote media is loaded:

ott app development

Customizing Cast Widgets

You can customize Cast widgets by setting the colors, styling the buttons, text, and thumbnail appearance, and by choosing the types of buttons to display.

Update res/values/styles_castvideo.xml

ott video platform

We hope you have a clearer understanding of what a Google Chromecast is and what it can do. With this detailed guide on cast-enabling a video app using the Cast SDK widgets on Android, we aim to give you proper insights with all the necessary steps. If you have any other queries about this guide, do reach out to us.

Javed Ali- Android Developer

Add a Comment

Your email address will not be published. Required fields are marked *

Looking for Streaming Solutions?

  • Go-Live on 12+ platforms
  • Zero Revenue Share
  • Multiple Monetization Models
  • 50+ Integrations

get a demo today

Take control of your digital media strategy.
Contact us for a no-obligation demo of the Experience
Cloud, tailor-made for you!