Slide 1

Slide 1 text

JORGE COCA - SPR CONSULTING TOPIC DATE SPEAKER THAT CONFERENCE 2015 CHROMECAST & ANDROID DELIVER AN INCREDIBLE EXPERIENCE FROM YOUR SMARTPHONE TO YOUR TV

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

SHOW ME AN EXAMPLE!

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

What is Chromecast? HDMI dongle $35 Smart TV Cast content from your device to your TV

Slide 7

Slide 7 text

You can cast content from… Android iOS Google Chrome

Slide 8

Slide 8 text

DO I NEED A CHROMECAST TO SEND CONTENT TO MY TV?

Slide 9

Slide 9 text

NO, BUT…

Slide 10

Slide 10 text

Cast-Ready devices Chromecast Android TV Cast for audio

Slide 11

Slide 11 text

ARCHITECTURE

Slide 12

Slide 12 text

How does it work? Two devices are involved in the process: SENDER: device used for discovery and media control RECEIVER: device used for streaming media (Cast- ready device)

Slide 13

Slide 13 text

Sender Will discover Cast-ready device (same Wifi network or guest access) Will discover media content and tell the Cast-ready device what to play Will behave as a remote control once the Cast-ready device is streaming content

Slide 14

Slide 14 text

IT WILL BE OUR “MOBILE” APP

Slide 15

Slide 15 text

Receiver Will stream media content that the sender tells it to reproduce Can display informative content while in “idle” mode

Slide 16

Slide 16 text

IT WILL BE AN “HTML5” WEBSITE DISPLAYED ON OUR TV CONTROLLED BY OUR “SENDER” APP

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Step by step - Connection (1/3) 1) Receiver advertises itself in the “same network” 2) Sender will discover receiver and will give the option to establish connection with the receiver 3) If user decides to connect, a web socket will be opened between sender and receiver

Slide 19

Slide 19 text

Step by step - Media discovery (2/3) 1) Receiver will fetch its first HTML5 screen (Splash Screen) 2) User will select media to play in the sender app, and the sender app will send the URL that the receiver should play

Slide 20

Slide 20 text

Step by step - Streaming content (3/3) 1) Media is downloaded and streamed by the receiver 2) HTML5 receiver app receives media request and starts playing the content

Slide 21

Slide 21 text

WAIT WAIT WAIT!!!

Slide 22

Slide 22 text

DO I HAVE TO WRITE TWO DIFFERENT APPS?

Slide 23

Slide 23 text

WITH TWO DIFFERENT LANGUAGES?

Slide 24

Slide 24 text

FOR TWO DIFFERENT DEVICES?

Slide 25

Slide 25 text

YES!

Slide 26

Slide 26 text

AND YOU WILL HAVE TO DESIGN ALSO FOR TWO DIFFERENT DEVICES…

Slide 27

Slide 27 text

…THAT HAVE NOTHING IN COMMON!

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

… BUT GOOGLE WILL PROVIDE SOME “MAGIC” TOOL TO MAKE THE DEVELOPMENT PROCESS EASIER, RIGHT?

Slide 30

Slide 30 text

THE ANSWER IS…

Slide 31

Slide 31 text

DEPENDS

Slide 32

Slide 32 text

Google Cast SDK For sender apps: Full set of APIs for Android (Java), iOS (Objective-C & Swift) and Chrome (Javascript) For receiver apps: HTML5/Javascript APIs

Slide 33

Slide 33 text

THE PROBLEM IS…

Slide 34

Slide 34 text

YOUR APP IS TRYING TO CONQUER THE LIVING ROOM, SO USERS DON’T WANT TO DEAL WITH PROBLEMS, BUGS, CRASHES OR BAD UX

Slide 35

Slide 35 text

YOUR CHROMECAST APP MUST BE…

Slide 36

Slide 36 text

EASY TO USE

Slide 37

Slide 37 text

FAST

Slide 38

Slide 38 text

“AVAILABLE EVERYWHERE”

Slide 39

Slide 39 text

THIS IS NOT EASY TO DO

Slide 40

Slide 40 text

SO YES, GOOGLE HAS SOME “MAGIC TOOLS”

Slide 41

Slide 41 text

THAT ARE ONLY VALID FOR SOME SCENARIOS

Slide 42

Slide 42 text

LUCKILY FOR US…

Slide 43

Slide 43 text

IT WILL COVER MOST OF THE SCENARIOS!

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

WHAT ARE THOSE SCENARIOS? WHAT’S THAT MAGIC TOOL?

Slide 46

Slide 46 text

GOOGLE CAST UX GUIDELINES

Slide 47

Slide 47 text

CAST COMPANION LIBRARY

Slide 48

Slide 48 text

Google Cast UX Guidelines - Key Ideas Your app is the remote It’s a shared experience It’s cross platform

Slide 49

Slide 49 text

INTRODUCE CAST THIS IS A ONE-TIME INTRODUCTION SCREEN, SO USERS CAN LEARN HOW TO USE CHROMECAST CAST ICON MUST VISIBLE FROM EVERY SCREEN CAST ICON LOCATION MUST CONSISTENT ACROSS THE APP PREFERRED LOCATION: RIGHT CORNER OF THE NAVIGATION BAR

Slide 50

Slide 50 text

SENDER DISCONNECTED RECEIVER SHOWS HOME SCREEN

Slide 51

Slide 51 text

Cast Button - States UNAVAILABLE: while receivers are not available, cast button doesn’t appear DISCONNECTED: the cast button appears if receivers are available CONNECTING: while the cast receiver is connecting, the cast button animates the waves CONNECTED: the cast button appears with a filled frame shape

Slide 52

Slide 52 text

CONNECT & PLAY

Slide 53

Slide 53 text

TAP CAST BUTTON RECEIVER DOES NOT CHANGE

Slide 54

Slide 54 text

SELECT A RECEIVER RECEIVER APP LOADING

Slide 55

Slide 55 text

SENDER IS CONNECTED RECEIVER APP IS LOADED / IDLE

Slide 56

Slide 56 text

SENDER PLAYS CONTENT - IT BEHAVES AS A REMOTE CONTROL RECEIVER IS PLAYING CONTENT

Slide 57

Slide 57 text

SENDER PLAYS CONTENT - IT BEHAVES AS A REMOTE CONTROL RECEIVER IS PLAYING CONTENT

Slide 58

Slide 58 text

… BUT YOU CAN ALSO PLAY & CONNECT

Slide 59

Slide 59 text

SENDER IS NOT CONNECTED - PLAYS MEDIA LOCALLY ON THE DEVICE RECEIVER SHOWS HOME SCREEN

Slide 60

Slide 60 text

TAP THE CAST BUTTON RECEIVER LOADS THE APP

Slide 61

Slide 61 text

TAP THE CAST BUTTON RECEIVER LOADS THE APP

Slide 62

Slide 62 text

SENDER PLAYS CONTENT - IT BEHAVES AS A REMOTE CONTROL RECEIVER IS PLAYING CONTENT

Slide 63

Slide 63 text

SENDER PLAYS CONTENT - IT BEHAVES AS A REMOTE CONTROL RECEIVER IS PLAYING CONTENT

Slide 64

Slide 64 text

CAST MENU

Slide 65

Slide 65 text

CAST MENU NOT CONNECTED RECEIVER SHOWS HOME SCREEN

Slide 66

Slide 66 text

CAST MENU - CONNECTED BUT NOT CASTING RECEIVER APP LOADED

Slide 67

Slide 67 text

CAST MENU - WHILE CASTING RECEIVER PLAYING CONTENT

Slide 68

Slide 68 text

CAST CONTROLS “AVAILABLE EVERYWHERE”

Slide 69

Slide 69 text

DEDICATED SCREEN

Slide 70

Slide 70 text

PERSISTENT CONTROLLER AVAILABLE IN ALL THE SCREENS OF YOUR APP

Slide 71

Slide 71 text

NOTIFICATION CONTROLS EVEN IF YOUR APP IS NO LONGER ACTIVE

Slide 72

Slide 72 text

LOCK SCREEN CONTROLS YOUR DEVICE NOW IS A TV REMOTE CONTROL, SO DON’T MAKE YOUR USERS WASTE THEIR TIME

Slide 73

Slide 73 text

… AND DON’T FORGET VOLUME CONTROLS

Slide 74

Slide 74 text

WHAT IF WE LOSE CONNECTION WITH THE RECEIVER? WIFI DISCONNECTION BATTERY DIES APP PROCESS STOPPED

Slide 75

Slide 75 text

YOU SHOULD AUTO-RECONNECT

Slide 76

Slide 76 text

DISCONNECTING

Slide 77

Slide 77 text

ONLY DISCONNECT THE CAST WHEN THE LAST USER DISCONNECTS!

Slide 78

Slide 78 text

FINAL DESIGN TIPS

Slide 79

Slide 79 text

DON’T MAKE YOUR TV APP LOOK INTERACTIVE

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

YOUR TV ONLY SHOWS STATE

Slide 82

Slide 82 text

YOUR “PHONE” PROVIDES ACTIONS

Slide 83

Slide 83 text

HOW AM I SUPPOSED TO CODE ALL THAT?

Slide 84

Slide 84 text

CAST COMPANION LIBRARY THE MAGIG TOOL DEVELOPED BY GOOGLE

Slide 85

Slide 85 text

Cast Companion Library Wrapper around Cast SDK APIs Makes SUPER EASY to develop what’s on the UX guidelines Open source Available on Github: https://github.com/googlecast/CastCompanionLibrary-android

Slide 86

Slide 86 text

LET’S TALK ABOUT CODE!

Slide 87

Slide 87 text

… but first Developers must register a test device in the Cast Developer Console https://cast.google.com/publish/#/overview Developer fees: $5

Slide 88

Slide 88 text

Google Cast Developer Console Need to provide app info: package name Register your receiver Marketing details Get your CHROMECAST_APP_ID

Slide 89

Slide 89 text

MEET WOODY! MY LITTLE PROJECT FOR SHOWING HOW THE CAST COMPANION LIBRARY WORKS

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

Assumptions We already have an app with screens in place: Results screen with a list of movies with multiple frames for Popular movies, Most rated,… A details screen listing information about the selected movie A search screen We will have to check if Google Play Services are available

Slide 92

Slide 92 text

Architecture We will build a BaseChromecastActivity, and all the activities in our app will inherit from it Will only contain Cast related code ActionBarActivity BaseChromecastActivity Rest of activities of the app

Slide 93

Slide 93 text

Our goals are… 1. Add cast icon 2. Introduce cast to first time users 3. Connect to a Cast-ready device 4. Cast content 5. Add a mini controller in our app 6. Add a sticky notification with media controls 7. Add a lock screen with media controls 8. Auto-reconnect when connection is lost

Slide 94

Slide 94 text

KEY CONCEPTS

Slide 95

Slide 95 text

CastManager It is the brain of the Cast functionality. It will update the NotificationService and the MiniController accordingly. BaseCastManager: abstract class that handles most of connectivity issues that transcends the lifecycle of individual activities. VideoCastManager: designed for video-centric apps

Slide 96

Slide 96 text

HOW DO WE USE THE VIDEOCASTMANAGER?

Slide 97

Slide 97 text

VideoCastManager public class WoodyApplication extends Application { @Override public void onCreate() { super.onCreate(); videoCastManager = VideoCastManager.initialize(getApplicationContext(), Constants.CHROMECAST_APP_ID, null, null); videoCastManager.enableFeatures(VideoCastManager.FEATURE_NOTIFICATION | VideoCastManager.FEATURE_LOCKSCREEN | VideoCastManager.FEATURE_WIFI_RECONNECT | VideoCastManager.FEATURE_CAPTIONS_PREFERENCE | VideoCastManager.FEATURE_DEBUGGING); } }

Slide 98

Slide 98 text

VideoCastManager public class WoodyApplication extends Application { @Override public void onCreate() { super.onCreate(); videoCastManager = VideoCastManager.initialize(getApplicationContext(), Constants.CHROMECAST_APP_ID, null, null); videoCastManager.enableFeatures(VideoCastManager.FEATURE_NOTIFICATION | VideoCastManager.FEATURE_LOCKSCREEN | VideoCastManager.FEATURE_WIFI_RECONNECT | VideoCastManager.FEATURE_CAPTIONS_PREFERENCE | VideoCastManager.FEATURE_DEBUGGING); } }

Slide 99

Slide 99 text

VideoCastManager public class WoodyApplication extends Application { @Override public void onCreate() { super.onCreate(); videoCastManager = VideoCastManager.initialize(getApplicationContext(), Constants.CHROMECAST_APP_ID, null, null); videoCastManager.enableFeatures(VideoCastManager.FEATURE_NOTIFICATION | VideoCastManager.FEATURE_LOCKSCREEN | VideoCastManager.FEATURE_WIFI_RECONNECT | VideoCastManager.FEATURE_CAPTIONS_PREFERENCE | VideoCastManager.FEATURE_DEBUGGING); } }

Slide 100

Slide 100 text

Our goals are… 1. Add cast icon 2. Introduce cast to first time users 3. Connect to a Cast-ready device 4. Cast content 5. Add a mini controller in our app 6. Add a sticky notification with media controls: ENABLED 7. Add a lock screen with media controls: ENABLED 8. Auto-reconnect when connection is lost: ENABLED

Slide 101

Slide 101 text

CAST ICON

Slide 102

Slide 102 text

menu.xml

Slide 103

Slide 103 text

menu.xml

Slide 104

Slide 104 text

BaseChromecastActivity public class BaseChromecastActivity extends ActionBarActivity { protected VideoCastManager videoCastManager; protected MiniController miniController; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); VideoCastManager.checkGooglePlayServices(this); videoCastManager = WoodyApplication.getCastManager(); showChromecastTutorial(); videoCastManager.reconnectSessionIfPossible(); }

Slide 105

Slide 105 text

Check for Google Play Services public class BaseChromecastActivity extends ActionBarActivity { protected VideoCastManager videoCastManager; protected MiniController miniController; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); VideoCastManager.checkGooglePlayServices(this); videoCastManager = WoodyApplication.getCastManager(); showChromecastTutorial(); videoCastManager.reconnectSessionIfPossible(); }

Slide 106

Slide 106 text

BaseChromecastActivity @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_base_navigation, menu); mediaRouteMenuItem = videoCastManager .addMediaRouterButton(menu, R.id.media_route_menu_item); return true; }

Slide 107

Slide 107 text

BaseChromecastActivity @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_base_navigation, menu); mediaRouteMenuItem = videoCastManager .addMediaRouterButton(menu, R.id.media_route_menu_item); return true; }

Slide 108

Slide 108 text

Our goals are… 1. Add cast icon: DONE 2. Introduce cast to first time users 3. Connect to a Cast-ready device: DONE 4. Cast content 5. Add a mini controller in our app 6. Add a sticky notification with media controls: ENABLED 7. Add a lock screen with media controls: ENABLED 8. Auto-reconnect when connection is lost: ENABLED

Slide 109

Slide 109 text

LET’S PLAY SOME CONTENT! VIDEOCASTCONTROLLERACTIVITY WILL PROVIDE A DEFAULT IMPLEMENTATION OF THE PLAYER CONTROL SCREEN

Slide 110

Slide 110 text

Register this new Activity

Slide 111

Slide 111 text

Play content MediaInfo mediaInfo = buildMediaInfo(); Intent intent = new Intent(getActivity(), VideoCastControllerActivity.class); intent.putExtra(Constants.EXTRA_MEDIA, Utils.fromMediaInfo(mediaInfo)); intent.putExtra(Constants.EXTRA_SHOULD_START, true); startActivity(intent);

Slide 112

Slide 112 text

Play content MediaInfo mediaInfo = buildMediaInfo(); Intent intent = new Intent(getActivity(), VideoastControllerActivity.class); intent.putExtra(Constants.EXTRA_MEDIA, Utils.fromMediaInfo(mediaInfo)); intent.putExtra(Constants.EXTRA_SHOULD_START, true); startActivity(intent);

Slide 113

Slide 113 text

MediaInfo private MediaInfo buildMediaInfo() { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_TITLE, movieDetails.getTitle()); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, movieDetails.getGenresWithCommas()); movieMetadata.putString(MediaMetadata.KEY_STUDIO, movieDetails.getProductionCompaniesWithCommas()); movieMetadata.addImage(new WebImage(Uri.parse(movieDetails.getPosterPath()))); return new MediaInfo.Builder(movieDetails.getMovieUrl()) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("video/mp4") .setMetadata(movieMetadata) .build(); }

Slide 114

Slide 114 text

MediaInfo private MediaInfo buildMediaInfo() { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_TITLE, movieDetails.getTitle()); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, movieDetails.getGenresWithCommas()); movieMetadata.putString(MediaMetadata.KEY_STUDIO, movieDetails.getProductionCompaniesWithCommas()); movieMetadata.addImage(new WebImage(Uri.parse(movieDetails.getPosterPath()))); return new MediaInfo.Builder(movieDetails.getMovieUrl()) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("video/mp4") .setMetadata(movieMetadata) .build(); }

Slide 115

Slide 115 text

Our goals are… 1. Add cast icon: DONE 2. Introduce cast to first time users 3. Connect to a Cast-ready device: DONE 4. Cast content: DONE 5. Add a mini controller in our app 6. Add a sticky notification with media controls: ENABLED 7. Add a lock screen with media controls: ENABLED 8. Auto-reconnect when connection is lost: ENABLED

Slide 116

Slide 116 text

MINICONTROLLER WIDGET PROVIDED BY THE CAST COMPANION LIBRARY

Slide 117

Slide 117 text

In your BaseChromecastActivity layout

Slide 118

Slide 118 text

BaseChromecastActivity @Override protected void onResume() { super.onResume(); videoCastManager = WoodyApplication.getCastManager(); miniController.setOnMiniControllerChangedListener(videoCastManager); videoCastManager.incrementUiCounter(); } @Override protected void onPause() { super.onPause(); videoCastManager.decrementUiCounter(); miniController.removeOnMiniControllerChangedListener(videoCastManager); }

Slide 119

Slide 119 text

BaseChromecastActivity @Override protected void onResume() { super.onResume(); videoCastManager = WoodyApplication.getCastManager(); miniController.setOnMiniControllerChangedListener(videoCastManager); videoCastManager.incrementUiCounter(); } @Override protected void onPause() { super.onPause(); videoCastManager.decrementUiCounter(); miniController.removeOnMiniControllerChangedListener(videoCastManager); }

Slide 120

Slide 120 text

BaseChromecastActivity @Override protected void onDestroy() { if (videoCastManager != null) { miniController.removeOnMiniControllerChangedListener(videoCastManager); videoCastManager.removeMiniController(miniController); videoCastManager.clearContext(this); } super.onDestroy(); }

Slide 121

Slide 121 text

BaseChromecastActivity @Override public void setContentView(final int layoutResID) { RelativeLayout layout = (RelativeLayout) getLayoutInflater() .inflate(R.layout.activity_base_chromecast, null); miniController = (MiniController) layout.findViewById(R.id.mini_controller); videoCastManager.addMiniController(miniController); super.setContentView(layout); }

Slide 122

Slide 122 text

BaseChromecastActivity @Override public void setContentView(final int layoutResID) { RelativeLayout layout = (RelativeLayout) getLayoutInflater() .inflate(R.layout.activity_base_chromecast, null); miniController = (MiniController) layout.findViewById(R.id.mini_controller); videoCastManager.addMiniController(miniController); super.setContentView(layout); }

Slide 123

Slide 123 text

BaseChromecastActivity @Override protected void onResume() { super.onResume(); videoCastManager = WoodyApplication.getCastManager(); miniController.setOnMiniControllerChangedListener(videoCastManager); videoCastManager.incrementUiCounter(); } @Override protected void onPause() { super.onPause(); videoCastManager.decrementUiCounter(); miniController.removeOnMiniControllerChangedListener(videoCastManager); }

Slide 124

Slide 124 text

Our goals are… 1. Add cast icon: DONE 2. Introduce cast to first time users 3. Connect to a Cast-ready device: DONE 4. Cast content: DONE 5. Add a mini controller in our app: DONE 6. Add a sticky notification with media controls: ENABLED 7. Add a lock screen with media controls: ENABLED 8. Auto-reconnect when connection is lost: ENABLED

Slide 125

Slide 125 text

NOTIFICATION WITH MEDIA CONTROLS

Slide 126

Slide 126 text

THIS NOTIFICATION WILL APPEAR EVERY TIME OUR APP IS CASTING AND IS NOT THE ACTIVE APP

Slide 127

Slide 127 text

VideoCastNotificationService

Slide 128

Slide 128 text

Our goals are… 1. Add cast icon: DONE 2. Introduce cast to first time users 3. Connect to a Cast-ready device: DONE 4. Cast content: DONE 5. Add a mini controller in our app: DONE 6. Add a sticky notification with media controls: DONE 7. Add a lock screen with media controls: ENABLED 8. Auto-reconnect when connection is lost: ENABLED

Slide 129

Slide 129 text

Auto-Reconnect: ReconnectService Background service that handles reconnection logic when WIFI connectivity is lost

Slide 130

Slide 130 text

Our goals are… 1. Add cast icon: DONE 2. Introduce cast to first time users 3. Connect to a Cast-ready device: DONE 4. Cast content: DONE 5. Add a mini controller in our app: DONE 6. Add a sticky notification with media controls: DONE 7. Add a lock screen with media controls: ENABLED 8. Auto-reconnect when connection is lost: ENABLED

Slide 131

Slide 131 text

WHY DID WE SKIP THE LOCK SCREEN CONTROLS?

Slide 132

Slide 132 text

IT IS ALREADY IMPLEMENTED

Slide 133

Slide 133 text

Remember this code? private MediaInfo buildMediaInfo() { MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE); movieMetadata.putString(MediaMetadata.KEY_TITLE, movieDetails.getTitle()); movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, movieDetails.getGenresWithCommas()); movieMetadata.putString(MediaMetadata.KEY_STUDIO, movieDetails.getProductionCompaniesWithCommas()); movieMetadata.addImage(new WebImage(Uri.parse(movieDetails.getPosterPath()))); return new MediaInfo.Builder(movieDetails.getMovieUrl()) .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setContentType("video/mp4") .setMetadata(movieMetadata) .build(); }

Slide 134

Slide 134 text

Our goals are… 1. Add cast icon: DONE 2. Introduce cast to first time users 3. Connect to a Cast-ready device: DONE 4. Cast content: DONE 5. Add a mini controller in our app: DONE 6. Add a sticky notification with media controls: DONE 7. Add a lock screen with media controls: DONE 8. Auto-reconnect when connection is lost: ENABLED

Slide 135

Slide 135 text

INTRODUCE CAST TO FIRST TIME USERS USING THE SHOW CASE VIEW LIBRARY (DEVELOPED BY @AMLCURRAN)

Slide 136

Slide 136 text

ShowCaseView Not included in the CastCompanionLibrary, but used by Google in their examples https://github.com/amlcurran/ShowcaseView Easy to customize: styles.xml

Slide 137

Slide 137 text

BaseChromecastActivity public class BaseChromecastActivity extends ActionBarActivity { protected VideoCastManager videoCastManager; protected MiniController miniController; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); VideoCastManager.checkGooglePlayServices(this); videoCastManager = WoodyApplication.getCastManager(); showChromecastTutorial(); videoCastManager.reconnectSessionIfPossible(); }

Slide 138

Slide 138 text

BaseChromecastActivity public class BaseChromecastActivity extends ActionBarActivity { protected VideoCastManager videoCastManager; protected MiniController miniController; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); VideoCastManager.checkGooglePlayServices(this); videoCastManager = WoodyApplication.getCastManager(); showChromecastTutorial(); videoCastManager.reconnectSessionIfPossible(); }

Slide 139

Slide 139 text

ShowCaseView private void showChromecastTutorial() { Menu menu = toolbar.getMenu(); View view = menu.findItem(R.id.media_route_menu_item).getActionView(); if (view != null && view instanceof MediaRouteButton) { new ShowcaseView.Builder(this) .setTarget(new ViewTarget(view)) .setContentTitle("Touch here to cast videos") .build(); SharedPreferencesUtils.saveBooleanSharedPreferences(this, PREF_USER_LEARNED_CHROMECAST, true); } }

Slide 140

Slide 140 text

ShowCaseView private void showChromecastTutorial() { Menu menu = toolbar.getMenu(); View view = menu.findItem(R.id.media_route_menu_item).getActionView(); if (view != null && view instanceof MediaRouteButton) { new ShowcaseView.Builder(this) .setTarget(new ViewTarget(view)) .setContentTitle("Touch here to cast videos") .build(); SharedPreferencesUtils.saveBooleanSharedPreferences(this, PREF_USER_LEARNED_CHROMECAST, true); } }

Slide 141

Slide 141 text

Our goals are… 1. Add cast icon: DONE 2. Introduce cast to first time users: DONE 3. Connect to a Cast-ready device: DONE 4. Cast content: DONE 5. Add a mini controller in our app: DONE 6. Add a sticky notification with media controls: DONE 7. Add a lock screen with media controls: DONE 8. Auto-reconnect when connection is lost: ENABLED

Slide 142

Slide 142 text

COOL, RIGHT?

Slide 143

Slide 143 text

LET’S CODE THE RECEIVER!

Slide 144

Slide 144 text

LET’S CODE THE RECEIVER STYLED MEDIA RECEIVER

Slide 145

Slide 145 text

No content

Slide 146

Slide 146 text

StyledMediaReceiver .background { background: #0c1821; } .logo { background-image: url("http://your_url.com/woody_transparent.png"); } .progressBar { background-color: #d7263d; } .splash { background-image: url("http://your_url.com/splash.png") } .watermark { background-image: url("http://your_url.com/watermark.png"); background-size: 100px 100px; }

Slide 147

Slide 147 text

DO YOU WANT TO SEE THE RESULTS?

Slide 148

Slide 148 text

No content

Slide 149

Slide 149 text

WHY SHOULD I ADD CAST SUPPORT IN MY APP?

Slide 150

Slide 150 text

No content

Slide 151

Slide 151 text

No content

Slide 152

Slide 152 text

COMEDY CENTRAL SEES 50% MORE VIDEOS VIEWED BY CHROMECAST USERS

Slide 153

Slide 153 text

JUST DANCE NOW SEES 2.5X MONETIZATION WITH CHROMECAST USERS

Slide 154

Slide 154 text

FITNET SEES 35% HIGHER ENGAGEMENT IN CHROMECAST USERS

Slide 155

Slide 155 text

HAYSTACK TV DOUBLED AVERAGE WEEKLY VIEWING TIME

Slide 156

Slide 156 text

Find this presentation ThatConference 2015 https://speakerdeck.com/jorgecoca/thatconference-2015 Chicago Code Camp 2015 https://speakerdeck.com/jorgecoca/chromecast-and-android

Slide 157

Slide 157 text

Follow me on Twitter & Github @jcocaramos jorgecoca

Slide 158

Slide 158 text

We’re Hiring!

Slide 159

Slide 159 text

No content

Slide 160

Slide 160 text

No content

Slide 161

Slide 161 text

No content