ChromeCast Java API v2 Build Status

At the moment I have started implementing this library, there was a java implementation of V1 Google ChromeCast protocol, which seems to be deprecated and does not work for newly created applications. The new V2 protocol is implemented by tools that come with Cast SDK, which is available for Android, iOS and Chrome Extension as javascript. Also there is a third party implementation of V2 in Node.js. This project is a third party implementation of Google ChromeCast V2 protocol in java.


Library is available in maven central. Put lines below into you project's pom.xml file:


Or to build.gradle (mavenCentral() repository should be included in appropriate block):

dependencies {
// ...
    compile 'su.litvak.chromecast:api-v2:0.11.3'
// ...


To build library from sources:

1) Clone github repo

$ git clone

2) Change to the cloned repo folder and run mvn install

$ cd chromecast-java-api-v2
$ mvn install

3) Then it could be included into project's pom.xml from local repository:



This is still a work in progress. The API is not stable, the quality is pretty low and there are a lot of bugs.

To use the library, you first need to discover what Chromecast devices are available on the network.


Then wait until some device discovered and it will be available in list. Then device should be connected. After that one can invoke several available operations, like check device status, application availability and launch application:

ChromeCast chromecast = ChromeCasts.get().get(0);
// Connect (optional) 
// Needed only when 'autoReconnect' is 'false'. 
// Usually not needed and connection will be established automatically.
// chromecast.connect();
// Get device status
Status status = chromecast.getStatus();
// Run application if it's not already running
if (chromecast.isAppAvailable("APP_ID") && !status.isAppRunning("APP_ID")) {
  Application app = chromecast.launchApp("APP_ID");

To start playing media in currently running media receiver:

// play media URL directly
// play media URL with additional parameters, such as media title and thumbnail image
chromecast.load("Big Buck Bunny",           // Media title
                "images/BigBuckBunny.jpg",  // URL to thumbnail based on media URL
                "", // media URL
                null // media content type (optional, will be discovered automatically)

Then playback may be controlled with following methods:

// pause playback
// continue playback;
// rewind (move to specified position (in seconds);
// update volume
// mute
// unmute (will set up volume to value before muting)

Also there are utility methods to get current chromecast status (running app, etc.) and currently played media status:

Status status = chromecast.getStatus();
MediaStatus mediaStatus = chromecast.getMediaStatus();

Current running application may be stopped by calling stopApp() method without arguments:

// Stop currently running application

Don't forget to close connection to ChromeCast device by calling disconnect():

// Disconnect from device

Finally, stop device discovery:


Alternatively, ChromeCast device object may be created without discovery if address of chromecast device is known:

ChromeCast chromecast = new ChromeCast("");

Since v.0.9.0 there is a possibility to send custom requests using send() methods. It is required to implement at least Request interface for an objects being sent to the running application. If some response is expected then Response interface must be implemented. For example to send request to the DashCast application:

Request interface implementation

public class DashCastRequest implements Request {
    final String url;
    final boolean force;
    final boolean reload;
    final int reloadTime;

    private Long requestId;

    public DashCastRequest(String url,
                           boolean force,
                           boolean reload,
                           int reloadTime) {
        this.url = url;
        this.force = force;
        this.reload = reload;
        this.reloadTime = reloadTime;

    public Long getRequestId() {
        return requestId;

    public void setRequestId(Long requestId) {
        this.requestId = requestId;

Sending request

chromecast.send("urn:x-cast:es.offd.dashcast", new DashCastRequest("", true, false, 0));

This is it for now. It covers all my needs, but if someone is interested in more methods, I am open to make improvements.

Useful links

Projects using library


(Apache v2.0 license)

Copyright (c) 2014 Vitaly Litvak [email protected]