SlideShare a Scribd company logo
1 of 35
Developing Apps for Chromecast
Kurt Mbanje
Overview
• Google Cast & Cast SDK
• Cast devices
• Cast components
• Android sender application
• Cast receiver application
• Chromecast Soundboard demo
Google Cast & Cast SDK
• Technology to cast to compatible devices
e.g. Chromecast & Android Tv
• Supports Android, IOS 8+ Chrome 32+ &
Cast extension 14.123.1.2+
Cast compatible devices
Cast Components
Sample Application
Cast Sound Board
https://github.com/ckurtm/CastSoundBoard
Receiver Application
Registration
Receiver Registration
Receiver Registration
Receiver Registration
Receiver Lifecycle
Receiver Development
<script type="text/javascript" src=“//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"/>
window.onload = function() {
loadSounds();
cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG);
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
console.log('starting the receiver application');
castReceiverManager.onReady = function(event) {
console.log('receiver application is ready: ' + JSON.stringify(event.data));
window.castReceiverManager.setApplicationState('Application status is ready...');
};
castReceiverManager.onSenderConnected = function(event) {
console.log('sender application connected: ' + event.data);
console.log(window.castReceiverManager.getSender(event.data).userAgent);
};
castReceiverManager.onSenderDisconnected = function(event) {
console.log('sender application disconnected: ' + event.data);
//if we dont have any connected devices then just close this app, this might not be necessary for your use case though
if (window.castReceiverManager.getSenders().length == 0) {
window.close();
}
};//register the namespace that we can handle messaging from. NOTE, THIS SHOULD be the same as the one the SENDER app uses to send
messages
window.messageBus = window.castReceiverManager.getCastMessageBus('urn:x-cast:mbanje.kurt.soundboard');
//handler for the incoming CastMessageBus message events from sender applications
window.messageBus.onMessage = function(event) {
console.log('Message [' + event.senderId + ']: ' + event.data);
var json = JSON.parse(event.data);
processMessage(json);
}
// initialize the CastReceiverManager with an application status message
window.castReceiverManager.start({statusText: 'Application is starting'});
console.log('Receiver Manager started');
Sender Application
Sender Lifecycle
Sender Development
Implementation
• Add dependency
• Add cast button
• Initialize
• Connect to cast device
• Listen for events
• Send messages
• Disconnect
Build.gradle
dependencies {
compile 'com.google.android.gms:play-services-cast-framework:10.0.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:mediarouter-v7:25.1.1'
}
<!—-menu.xml—>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/media_route_menu_item"
android:title="@string/cast_menu"
app:actionProviderClass="android.support.v7.app.MediaRouteActionProvider"
app:showAsAction="always" />
</menu>
menu/main.xml
public class CastOptionsProvider implements OptionsProvider {
//This is the custom namespace we will use to communicate with the cast receiver application
public static final String NAMESPACE = "urn:x-cast:mbanje.kurt.soundboard";
@Override
public CastOptions getCastOptions(Context context) {
CastOptions castOptions = new CastOptions.Builder()
.setReceiverApplicationId(context.getString(R.string.app_id))
.build();
return castOptions;
}
@Override
public List<SessionProvider> getAdditionalSessionProviders(Context context) {
return null;
}
}
OptionsProvider
<!—AndroidManifest.xml—>
<meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="mbanje.kurt.soundboard.CastOptionsProvider" />
<android.support.v7.app.MediaRouteButton
android:id="@+id/media_route_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
layout.xml
private void setUpCastIcon() {
MediaRouteButton castButton = (MediaRouteButton) findViewById(R.id.media_route_button);
CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), castButton);
CastContext castContext = CastContext.getSharedInstance(this);
sessionManager = castContext.getSessionManager();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu, R.id.media_route_menu_item);
return true;
}
@Override
protected void onResume() {
sessionManager.addSessionManagerListener(castSessionListener);
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
sessionManager.removeSessionManagerListener(castSessionListener);
}
Activity Setup
final JSONObject obj = new JSONObject();
obj.put("action",isChecked?ACTION_PLAY:ACTION_STOP);
obj.put("sound",sound);
final String json = obj.toString(1);
//we only send the message if we have an active session
if(buttonView.isEnabled() && sessionManager.getCurrentCastSession() != null) {
sessionManager.getCurrentCastSession().sendMessage(CastOptionsProvider.NAMESPACE, json).setResultCallback(new
ResultCallback<Status>() {
@Override
public void onResult(@NonNull final Status status) {
if (status.isSuccess()) {
Log.d(TAG, "message sent successfully: " + json);
} else {
Log.e(TAG, "failed to send message: " + json);
}
}
});
}
Activity Send Messages
Google Cast SDK
Cast Video
RemoteMediaClient remoteMediaClient =
CastContext.getSharedInstance(this).getSessionManager().getCurrentCast
Session().getRemoteMediaClient();
MediaInfo mediaInfo = new
MediaInfo.Builder(getString(R.string.movie_link))
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("videos/mp4")
.build();
remoteMediaClient.load(mediaInfo, true, 0);
UI Components
• Introductory Overlay
• Expanded Controls
• Minicontroller
• Notification Screen
Thank You
https://github.com/ckurtm/CastSoundBoard
+KurtMbanje
@ckurtm
www.peirr.com

More Related Content

Similar to Custom Chromecast Receiver Application

Desenvolver para Chromecast
Desenvolver para ChromecastDesenvolver para Chromecast
Desenvolver para ChromecastPedro Veloso
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMohammad Shaker
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureVijay Rastogi
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspectiveGunjan Kumar
 
Android OS & SDK - Getting Started
Android OS & SDK - Getting StartedAndroid OS & SDK - Getting Started
Android OS & SDK - Getting StartedHemant Chhapoliya
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)Google
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Androidtdc-globalcode
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guidemagicshui
 
The chromecast's guide to the galaxy
The chromecast's guide to the galaxyThe chromecast's guide to the galaxy
The chromecast's guide to the galaxyRoc Boronat
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018 AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018 Theerasan Tonthongkam
 
Fancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRFancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRVladimir Georgiev
 
android level 3
android level 3android level 3
android level 3DevMix
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)DroidConTLV
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 

Similar to Custom Chromecast Receiver Application (20)

Desenvolver para Chromecast
Desenvolver para ChromecastDesenvolver para Chromecast
Desenvolver para Chromecast
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
 
Android App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structureAndroid App development and test environment, Understaing android app structure
Android App development and test environment, Understaing android app structure
 
Integrando sua app Android com Chromecast
Integrando sua app Android com ChromecastIntegrando sua app Android com Chromecast
Integrando sua app Android com Chromecast
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspective
 
Android OS & SDK - Getting Started
Android OS & SDK - Getting StartedAndroid OS & SDK - Getting Started
Android OS & SDK - Getting Started
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Android
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Night Watch with QA
Night Watch with QANight Watch with QA
Night Watch with QA
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guide
 
The chromecast's guide to the galaxy
The chromecast's guide to the galaxyThe chromecast's guide to the galaxy
The chromecast's guide to the galaxy
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018 AndroidX Google Extended I/O BKK 2018
AndroidX Google Extended I/O BKK 2018
 
Fancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRFancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalR
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
 
android level 3
android level 3android level 3
android level 3
 
Android Presentation
Android PresentationAndroid Presentation
Android Presentation
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 

Recently uploaded

VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...Call Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Call Girls in Nagpur High Profile
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...Suhani Kapoor
 
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查awo24iot
 
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...ranjana rawat
 
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Pooja Nehwal
 
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...Call Girls in Nagpur High Profile
 
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...Pooja Nehwal
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样qaffana
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service ThanePooja Nehwal
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsPooja Nehwal
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...Call Girls in Nagpur High Profile
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...Call Girls in Nagpur High Profile
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...anilsa9823
 
Develop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointDevelop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointGetawu
 

Recently uploaded (20)

VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
 
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Chakan ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
 
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
如何办理(Adelaide毕业证)阿德莱德大学毕业证成绩单Adelaide学历认证真实可查
 
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
Book Paid Lohegaon Call Girls Pune 8250192130Low Budget Full Independent High...
 
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
 
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...Book Sex Workers Available Pune Call Girls Yerwada  6297143586 Call Hot India...
Book Sex Workers Available Pune Call Girls Yerwada 6297143586 Call Hot India...
 
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
 
Call Girls In Vaishali 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Vaishali 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In Vaishali 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Vaishali 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call Girls
 
young call girls in Sainik Farm 🔝 9953056974 🔝 Delhi escort Service
young call girls in Sainik Farm 🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Sainik Farm 🔝 9953056974 🔝 Delhi escort Service
young call girls in Sainik Farm 🔝 9953056974 🔝 Delhi escort Service
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
 
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
VVIP Pune Call Girls Balaji Nagar (7001035870) Pune Escorts Nearby with Compl...
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
 
Develop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power pointDevelop Keyboard Skill.pptx er power point
Develop Keyboard Skill.pptx er power point
 

Custom Chromecast Receiver Application

  • 1. Developing Apps for Chromecast Kurt Mbanje
  • 3. • Google Cast & Cast SDK • Cast devices • Cast components • Android sender application • Cast receiver application • Chromecast Soundboard demo
  • 4. Google Cast & Cast SDK • Technology to cast to compatible devices e.g. Chromecast & Android Tv • Supports Android, IOS 8+ Chrome 32+ & Cast extension 14.123.1.2+
  • 6.
  • 8.
  • 11.
  • 18.
  • 20. <script type="text/javascript" src=“//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"/> window.onload = function() { loadSounds(); cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG); window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance(); console.log('starting the receiver application'); castReceiverManager.onReady = function(event) { console.log('receiver application is ready: ' + JSON.stringify(event.data)); window.castReceiverManager.setApplicationState('Application status is ready...'); }; castReceiverManager.onSenderConnected = function(event) { console.log('sender application connected: ' + event.data); console.log(window.castReceiverManager.getSender(event.data).userAgent); }; castReceiverManager.onSenderDisconnected = function(event) { console.log('sender application disconnected: ' + event.data); //if we dont have any connected devices then just close this app, this might not be necessary for your use case though if (window.castReceiverManager.getSenders().length == 0) { window.close(); } };//register the namespace that we can handle messaging from. NOTE, THIS SHOULD be the same as the one the SENDER app uses to send messages window.messageBus = window.castReceiverManager.getCastMessageBus('urn:x-cast:mbanje.kurt.soundboard'); //handler for the incoming CastMessageBus message events from sender applications window.messageBus.onMessage = function(event) { console.log('Message [' + event.senderId + ']: ' + event.data); var json = JSON.parse(event.data); processMessage(json); } // initialize the CastReceiverManager with an application status message window.castReceiverManager.start({statusText: 'Application is starting'}); console.log('Receiver Manager started');
  • 24. Implementation • Add dependency • Add cast button • Initialize • Connect to cast device • Listen for events • Send messages • Disconnect
  • 25. Build.gradle dependencies { compile 'com.google.android.gms:play-services-cast-framework:10.0.1' compile 'com.android.support:appcompat-v7:25.1.1' compile 'com.android.support:mediarouter-v7:25.1.1' }
  • 26. <!—-menu.xml—> <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/media_route_menu_item" android:title="@string/cast_menu" app:actionProviderClass="android.support.v7.app.MediaRouteActionProvider" app:showAsAction="always" /> </menu> menu/main.xml
  • 27. public class CastOptionsProvider implements OptionsProvider { //This is the custom namespace we will use to communicate with the cast receiver application public static final String NAMESPACE = "urn:x-cast:mbanje.kurt.soundboard"; @Override public CastOptions getCastOptions(Context context) { CastOptions castOptions = new CastOptions.Builder() .setReceiverApplicationId(context.getString(R.string.app_id)) .build(); return castOptions; } @Override public List<SessionProvider> getAdditionalSessionProviders(Context context) { return null; } } OptionsProvider <!—AndroidManifest.xml—> <meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:value="mbanje.kurt.soundboard.CastOptionsProvider" />
  • 29. private void setUpCastIcon() { MediaRouteButton castButton = (MediaRouteButton) findViewById(R.id.media_route_button); CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), castButton); CastContext castContext = CastContext.getSharedInstance(this); sessionManager = castContext.getSessionManager(); } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.main, menu); CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu, R.id.media_route_menu_item); return true; } @Override protected void onResume() { sessionManager.addSessionManagerListener(castSessionListener); super.onResume(); } @Override protected void onPause() { super.onPause(); sessionManager.removeSessionManagerListener(castSessionListener); } Activity Setup
  • 30. final JSONObject obj = new JSONObject(); obj.put("action",isChecked?ACTION_PLAY:ACTION_STOP); obj.put("sound",sound); final String json = obj.toString(1); //we only send the message if we have an active session if(buttonView.isEnabled() && sessionManager.getCurrentCastSession() != null) { sessionManager.getCurrentCastSession().sendMessage(CastOptionsProvider.NAMESPACE, json).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull final Status status) { if (status.isSuccess()) { Log.d(TAG, "message sent successfully: " + json); } else { Log.e(TAG, "failed to send message: " + json); } } }); } Activity Send Messages
  • 32. Cast Video RemoteMediaClient remoteMediaClient = CastContext.getSharedInstance(this).getSessionManager().getCurrentCast Session().getRemoteMediaClient(); MediaInfo mediaInfo = new MediaInfo.Builder(getString(R.string.movie_link)) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("videos/mp4") .build(); remoteMediaClient.load(mediaInfo, true, 0);
  • 33. UI Components • Introductory Overlay • Expanded Controls • Minicontroller • Notification Screen