This repository has been archived by the owner. It is now read-only.
[DEPRECATED] CastCompanionLibrary-android is a library project to enable developers integrate Cast capabilities into their applications faster and easier.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 110 commits ahead of danhyun:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

[DEPRECATED] CastCompanionLibrary-android

This project is unmaintained and should not be used anymore. You should instead migrate your code to the Google Cast SDK v3 which is a complete rewrite of the Cast Companion Library including many fixes and improvements.

This is a fork of the Cast Companion Library for Android by Google. It features fixed bugs, easier integration, improved performance, simpler code and cleaned up resources.

CastCompanionLibrary-android is a library project to enable developers integrate Cast capabilities into their applications faster and easier.

IMPORTANT - Differences with the original library

Min SDK version

This library is compatible with API level 9 and above (the original library mentions API level 10 and above).

Manifest declaration

This library does not require any Intent filter declaration for the VideoCastNotificationService. This is a recap of what you must declare inside your manifest's <application> tag for video-centric applications:

    <receiver android:name="" >
            <action android:name="" />
            <action android:name="android.intent.action.MEDIA_BUTTON" />
            <action android:name="" />
            <action android:name="" />
            <action android:name="" />

        android:exported="false" />

        android:value="@integer/google_play_services_version" />

VideoCastManager initialization

You must initialize VideoCastManager (or DataCastManager) by calling its static initialize() method in your Application.onCreate() callback. This is because the services and activities of this library expect the VideoCastManager to be already initialized when they start up.


This library provides a pluggable image loading system to load the videos artwork in all its components. The default implementation features a simple network queue and a small memory cache. You may provide your own implementation instead, in order to use your favourite image loader library. To do so, you need to implement the interface. Read the interface documentation for more information. You can also find an implementation using the image loader of the Volley library.

You then need to pass your implementation as a last parameter to the VideoCastManager.initialize() method to enable it.


This library provides a base class named VideoCastActivity that your activities may inherit from for an easier integration in video-centric applications. It takes cares of the following automatically:

  • Retrieving the VideoCastManager instance in a protected field named mCastManager.
  • Updating the context of the VideoCastManager.
  • Handling hardware volume keys to control the Cast device volume when connected to it.
  • Calling incrementUiCounter() and decrementUiCounter() so the library can keep track of the visibility of your application's UI and act accordingly (show or hide the notification, look for Cast devices).
  • Optional: populating the Action Bar with a Cast button and initializing it.


This other base Activity provides the same features as VideoCastActivity, plus automatically registers and unregisters a MiniController. It requires that the layout of your Activity contains a MiniController widget with the id

Default volume increment step change

The default volume increment when using the hardware volume keys in activities inheriting from VideoCastActivity (including the default Cast Controller Activity) is 5% or 0.05. If you want to change it, you must call the static method VideoCastActivity.setVolumeIncrement(). For example, you can call it in Application.onCreate().

Contributors for this version

  • Christophe Beyls

If you use this version of the Cast Companion Library in your project, please link to this GitHub's project page and mention the author.


  • google-play-services_lib library from the Android SDK (at least version 4.3)
  • android-support-v7-appcompat (version 19.0.1 or above)
  • android-support-v7-mediarouter (version 19.0.1 or above)

Setup Instructions

  • Set up the project dependencies


See the "CastCompanionLibray.pdf" inside the project for a more extensive documentation.

References and How to report bugs

How to make contributions?

Please read and follow the steps in the




Google Cast Developers Community on Google+

Change List

1.4 -> 1.5

  • Fixed the issue where VideoCastNotificationService was not setting up data namespace if one was configured
  • Fixed issue 50
  • Added aversion number that will be printed in the log statements for tracking purposes
  • Correcting the typo in the name of method checkGooglePlaySevices() by introducing a new method and deprecating the old one (issue 48)
  • Fixing many typos in comments and some resources
  • Updating documentation to reflect the correct name of callbacks for the custom namespace for VideoCastManager

1.3 -> 1.4

  • Added support for MediaRouteButton
  • Added "alias" resources for Mini Controller play/pause/stop buttons so clients can customize them easily
  • Added a color resource to control thw color of the title of the custom VideoMediaRouteControllerDialog
  • Fixed some typos in JavaDoc

1.2 -> 1.3

  • Fixing issue 32
  • Fixing issue 33
  • Adding a better BaseCastManager.clearContext() variation
  • Implementing enhancement 30
  • Making sure play/pause button is hidden when ProgressBar is shown in VideoMediaRouteControllerDialog
  • probably some more adjustments and bug fixes

1.1 -> 1.2

  • Improving thread-safety in calling various ConsumerImpl callbacks
  • (backward incompatible) Changing the signature of IMediaAuthListener.onResult
  • Adding an API to BaseCastManager so clients can clear the "context" to avoid any leaks
  • Various bug fixes

1.0 -> 1.1

  • Added gradle build scripts (make sure you have Android Support Repository)
  • For live media, the "pause" button at various places is replaced with a "stop" button
  • Refactored the VideoCastControllerActivity to enable configuration changes without losing any running process
  • Added new capabilities for clients to hook in an authorization process prior to casting a video
  • A number of bug fixes, style fixes, etc
  • Updated documentation