SlideShare a Scribd company logo
Developing for Chromecast
Cast Companion Library & Custom Receiver Application
Kurt Mbanje
@ckurtm / peirr.com
What is Chromecast?
Developing for Chromecast on Android
Developing for Chromecast on Android
How does it work?
• Sender application
Two components
Applications running on a mobile device or laptop
• Receiver application
(HTML, JavaScript , CSS) app running on a Chromecast or other
cast compatible device.
• Sender application
Two components
Applications running on a mobile device or laptop
• Receiver application
(HTML, JavaScript , CSS) app running on a Chromecast or other
cast compatible device.
Receiver application
Developing for Chromecast on Android
Developing for Chromecast on Android
• Custom Media Receiver
3 Types of receivers
Requires application id , DRM Content, Data centric apps
• Styled Media Receiver
Can be styled with CSS files, requires application id
• Default Media Receiver
Does not require application id, can use
CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID in your sender if using CCL
Custom Receiver
www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js
Receiver API
Simple Custom Receiver
<head>
<title>LocalCast</title>
<script src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
<link rel="stylesheet" href="receiver.css"/>
</head>
<script>
//[3] handle the payload from the sender
function process(json){
console.log('received: ' + json.url);
document.getElementById("image").src= json.url;
}
//[1] get a handle to the receiver manager
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
castReceiverManager.onSenderDisconnected = function(event) {
console.log('disconnected: ' + event.data);
if (window.castReceiverManager.getSenders().length == 0) { //close the app if we have no more connected devices
window.close();
}
};
//[2] create a CastMessageBus to handle messages for a custom namespace
window.messageBus = window.castReceiverManager.getCastMessageBus('urn:x-cast:com.peirr.localcast');
window.messageBus.onMessage = function(event) {
var json = JSON.parse(event['data']); //decode the request from sender app
window.sender = event.senderId;
process(json);
}
//[4]start the listener
window.castReceiverManager.start();
</script>
Publishing Receiver
Application
• Development
• Publish to any server & add endpoint to cast
console
• Debug http://RECEIVER-IP-ADDRESS:9222
• Production
Server has to be secure (https://<yourserver>)
• Google Cast SDK Developer Console
https://cast.google.com/publish/
Publishing
• Development
• Publish to any server & add endpoint to cast
console
• Debug http://RECEIVER-IP-ADDRESS:9222
• Production
Server has to be secure (https://<yourserver>)
• Google Cast SDK Developer Console
https://cast.google.com/publish/
Publishing
• Development
• Publish to any server & add endpoint to cast
console
• Debug http://RECEIVER-IP-ADDRESS:9222
• Production
Server has to be secure (https://<yourserver>)
• Google Cast SDK Developer Console
https://cast.google.com/publish/
Publishing
Sender Application
Developing for Chromecast on Android
Android development options
compile "com.android.support:mediarouter-v7:23.3.0"
compile 'com.google.android.gms:play-services-cast:8.4.0'
compile "com.android.support:mediarouter-v7:23.3.0"
compile 'com.google.android.gms:play-services-cast:8.4.0'
compile 'com.google.android.libraries.cast.companionlibrary:ccl:2.8.3'
Cast Companion Library
Cast Companion Library
https://github.com/googlecast/CastCompanionLibrary-android
Example: LocalCast
https://github.com/ckurtm/LocalCast
Developing for Chromecast on Android
Initialize
CastConfiguration options =new CastConfiguration.Builder("84B70D9D")
.enableAutoReconnect()
.enableDebug()
.build();
DataCastManager.initialize(this,options);
Cast Button
<item
android:id="@+id/action_cast"
android:title="@string/action_cast"
app:actionProviderClass="android.support.v7.app.MediaRouteActionProvider"
app:showAsAction="always"/>
@Override
public boolean onCreateOptionsMenu(Menu menu){
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu,menu);
DataCastManager.getInstance().addMediaRouterButton(menu,R.id.action_cast);
return true;
}
Send data to Receiver Application
JSONObject obj = new JSONObject();
String url = "http://"+ info.ip + ":" + info.port + "/" + item.getFile().getAbsolutePath();
Log.d(TAG, "casting: " + url);
try {
obj.put("url",url);
DataCastManager.getInstance().sendDataMessage(obj.toString(),"urn:x-
cast:com.peirr.localcast");
} catch (JSONException|IOException e) {
e.printStackTrace();
}
Questions

More Related Content

PPTX
Developing for Chromecast on Android
PPTX
Custom Chromecast Receiver Application
PDF
Gradle 101
PPTX
Continuous Delivery to Kubernetes Using Helm
PPTX
Development environments in seconds using Bitnami containers
PDF
Building Translate on Glass
PDF
Introduction to Kubernetes and GKE
PDF
Thinking One Step Further with Time-saving DevOps Tools with Open Telekom Clo...
Developing for Chromecast on Android
Custom Chromecast Receiver Application
Gradle 101
Continuous Delivery to Kubernetes Using Helm
Development environments in seconds using Bitnami containers
Building Translate on Glass
Introduction to Kubernetes and GKE
Thinking One Step Further with Time-saving DevOps Tools with Open Telekom Clo...

What's hot (7)

PDF
Javaone - Gradle: Harder, Better, Stronger, Faster
PDF
Deploying containerized applications with Kubeapps
PDF
What you have to know about Certified Kubernetes Administrator (CKA)
PDF
Everything-as-code. A polyglot adventure. #DevoxxPL
PDF
Improve monitoring and observability for kubernetes with oss tools
PPTX
From development to production: Deploying Java and Scala apps to kubernetes
PDF
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
Javaone - Gradle: Harder, Better, Stronger, Faster
Deploying containerized applications with Kubeapps
What you have to know about Certified Kubernetes Administrator (CKA)
Everything-as-code. A polyglot adventure. #DevoxxPL
Improve monitoring and observability for kubernetes with oss tools
From development to production: Deploying Java and Scala apps to kubernetes
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
Ad

Similar to Developing for Chromecast on Android (20)

PDF
Cast your app to the big screen: Google Cast Android API
PPTX
Integrando sua app Android com Chromecast
PDF
Desenvolver para Chromecast
PPTX
Native client
PPTX
Chromecast get started
PDF
Urban Airship & Android Application Integration Document
PDF
Urban Airship and Android Integration for Push Notification and In-App Notifi...
PDF
Droidcon de 2014 google cast
PDF
윈도 닷넷 개발자를 위한 솔루션 클라우드 데브옵스 솔루션
PPTX
Deploying windows containers with kubernetes
PPTX
Deploy your favorite apps on Kubernetes
PDF
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
PPTX
Docker Orchestration: Welcome to the Jungle! Devoxx & Docker Meetup Tour Nov ...
PPTX
Interoute Virtual Data Centre api 101
PPTX
Iteratively Develop Microservices with Speed on Kubernetes
PPTX
Microsoft Windows Server AppFabric
PDF
Deploying a Java Application on Azure Kubernetes Service with Cosmos DB
PDF
When Smalltalk Meets the Web
PPTX
Real time Communication with Signalr (Android Client)
PDF
The chromecast's guide to the galaxy
Cast your app to the big screen: Google Cast Android API
Integrando sua app Android com Chromecast
Desenvolver para Chromecast
Native client
Chromecast get started
Urban Airship & Android Application Integration Document
Urban Airship and Android Integration for Push Notification and In-App Notifi...
Droidcon de 2014 google cast
윈도 닷넷 개발자를 위한 솔루션 클라우드 데브옵스 솔루션
Deploying windows containers with kubernetes
Deploy your favorite apps on Kubernetes
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Docker Orchestration: Welcome to the Jungle! Devoxx & Docker Meetup Tour Nov ...
Interoute Virtual Data Centre api 101
Iteratively Develop Microservices with Speed on Kubernetes
Microsoft Windows Server AppFabric
Deploying a Java Application on Azure Kubernetes Service with Cosmos DB
When Smalltalk Meets the Web
Real time Communication with Signalr (Android Client)
The chromecast's guide to the galaxy
Ad

Recently uploaded (10)

DOC
SIUE毕业证学历认证,阿祖萨太平洋大学毕业证学位证书复制
DOC
NIU毕业证学历认证,阿比林基督大学毕业证留学生学历
PPTX
Introduction to Packet Tracer Course Overview - Aug 21 (1).pptx
PDF
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
PDF
Kids, Screens & Emotional Development by Meenakshi Khakat
PDF
Best 4 Sites for Buy Verified Cash App Accounts – BTC Only.pdf
DOC
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
PDF
2025 Guide to Buy Verified Cash App Accounts You Can Trust.pdf
PPTX
Social Media People PowerPoint Templates.pptx
PPTX
ASMS Telecommunication company Profile
SIUE毕业证学历认证,阿祖萨太平洋大学毕业证学位证书复制
NIU毕业证学历认证,阿比林基督大学毕业证留学生学历
Introduction to Packet Tracer Course Overview - Aug 21 (1).pptx
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
Kids, Screens & Emotional Development by Meenakshi Khakat
Best 4 Sites for Buy Verified Cash App Accounts – BTC Only.pdf
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
2025 Guide to Buy Verified Cash App Accounts You Can Trust.pdf
Social Media People PowerPoint Templates.pptx
ASMS Telecommunication company Profile

Developing for Chromecast on Android