SlideShare uma empresa Scribd logo
1 de 42
Baixar para ler offline
Video Streaming 
from the native Android player 
to uncoventional devices 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Open Reply & Android Lab 
• Reply is today a leading IT Services Company 
• Operates in Italy, Germany, UK, Benelux, USA and Brasil. 
• Open Reply is the company of Reply Group focused on open source software, 
multichannel web solutions and mobile applications. 
• Based in Rome, Open Reply’s Android Lab is a young team of over 20 engineers 100% 
focused on Android development. 
• We are specialised in broadcasting, banking and Android OS Customisation. 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Presentation Millestones 
• Playing a content on your handheld device. 
• Entertaiment tailored for the user with 
• Easiest way to enjoy online video and music on user TV on 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Android multimedia framework 
• Android support for playing several media types from media file stored inside the 
application (raw resources, standalone files) or for OTT streaming. 
• Documentation of the media framework is enough just for simple test case. 
• Underneath MediaPlayer Framework documentation is kind of nightmare (lot of 
events and error are not documented at all). 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Supported type 
HttpLiveStreaming Protocol 3 is supported by Android 4.0. Best implementation is in 
Kitkat. 
Google seems putting all his efforts to support new media type ( SmoothStreaming, 
Dynamic adaptive streaming) 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Playing a video 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
VideoView 
Three different approaches 
Mediaplayer 
& 
SurfaceView 
ExoPlayer
MediaPlayer code example 
android.widget.VideoView 
//1. Find the view from the layout 
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview); 
//2. Setup video url 
myVideoView.setVideoURI(Uri.parse(SrcPath)); 
//3. Setup Video controller 
myVideoView.setMediaController(new MediaController(this)); 
//4. Start playing 
myVideoView.requestFocus(); 
myVideoView.start(); 
Programmer doesn’t directly 
handle the MediaPlayer 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
MediaPlayer code example 
android.media.Mediaplayer 
//0. Get SurfaceView and its holder 
mPreview = (SurfaceView)findViewById(R.id.surfaceView); 
holder = mPreview.getHolder(); 
//1. Create MediaPlayer object: 
mp = new MediaPlayer(); 
//2. Add SurfaceHolder callback - Aware when SurfaceView is created 
holder.addCallback(new SurfaceHolder.Callback(){ .... 
@Override 
public void surfaceCreated(SurfaceHolder holder) { 
android.view.SurfaceView 
//3. Attach the surface to the player 
mp.setDisplay(holder); 
try { 
mp.setDataSource(filepath); 
//4. Prepare the Mediaplayer in sync or async mode ( prepareAsync() ) 
mp.prepare(); 
} catch (Exception e) {// Catch the exception} 
//5. Start the player 
mp.start(); 
}... 
}); 
& 
Application creates SurfaceView and MediaPlayer. 
More control on MediaPlayer state 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
MediaPlayer code example 
// 1. Instantiate the player. 
player = ExoPlayer.Factory.newInstance(RENDERER_COUNT); 
// 2. Construct renderers. 
ExoPlayer 
MediaCodecVideoTrackRenderer videoRenderer = … 
MediaCodecAudioTrackRenderer audioRenderer = ... 
// 3. Inject the renderers through prepare. 
player.prepare(videoRenderer, audioRenderer); 
// 4. Pass the surface to the video renderer. 
player.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface); 
// 5. Start playback. 
player.setPlayWhenReady(true); 
... 
player.release(); // Release when everything is done! 
Pre-built player that can be extend. 
Implement features not currently 
supported in the normal mediaplayer. 
Droidcon London – 2014 – Matteo Bonifazi e Alessandro Martellucci
What kind of Mediaplayer exist? 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
• Built-in players 
ü AwesomePlayer (default player selected) 
ü NuPlayer (Apple HLS) 
• Extra player factories can be registered 
• DIY mediaplayer 
ü Demuxing: android.media.mediaExtractor 
ü Decoding: android.media.MediaCodec 
ü Video rendering: android.media.MediaCodec 
ü Audio rendering: android.media.AudioTrack 
ü Implement the interface frameworks/av/include/media/MediaPlayerInterface.h
Android TV 
Entertainment tailored for you 
Source:h)p://www.televisedrevolu4on.com/ 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Nexus Player 
Source:h)p://www.televisedrevolu4on.com/ 
Asus device – 235 g 
1.8GHz Quad Core, Intel® Atom™ 
Imagination PowerVR Series 6 
Graphics 2D/3D Engine 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
1GB RAM 
8GB storage
Android TV app 
features 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
• Android 
TV 
devices 
have 
Android 
Lollipop 
5.0 
on 
board. 
• Android 
TV 
has 
inside 
the 
same 
Android 
mul4media 
framework 
of 
normal 
devices. 
• Android 
TV 
app 
can 
be 
built 
on 
API 
17 
towards. 
• Based 
on 
Leanback 
Android 
Support 
library
10 feet experience 
Smartphone 5” 
320 dp 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
TV Full HD 30” 
320 dpi 
10 feet 
16 inches
Manifest features 
Support landscape 
Portrait activity are forbidden 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Manifest features 
No touch screen 
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/> 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Manifest features 
Limit sensor 
<uses-feature android:name="android.hardware.sensor.accelerometer” 
android:required="false" /> 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Keep calm and lean back!! 
Provides built-in tailored for 10 feet experience 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback support library 
<uses-feature android:name="android.software.leanback" 
android:required="true" /> 
<application 
android:allowBackup="false” 
android:label="@string/app_name” 
android:theme="@style/Theme.Leanback" > 
<activity 
android:name="MainActivity” 
android:screenOrientation="landscape" > 
<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> 
</intent-filter> 
</activity> 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback support library 
Model View Presenter 
Model 
Presenter 
View 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback UI component 
BroswerFragment 
allows the developer “to create a primary layout for browsing categories and rows of 
media items [with a minimum of code]” 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Leanback UI component 
DetailFragment 
Display information about the content that the user has selected 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast 
a cast-ready device for multi-screen experience 
source: www.google.it 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast 
hardware specifications 
source: www.pcworld.com 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Chromecast 
components 
• Google Cast technology 
• Multi-Screen experiece 
• Google Cast SDK 
• Sender Application 
• Android app 
• iOS app 
• Chrome app 
• Receiver Application 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
• Default Media Receiver 
• Styled Media Receiver 
• Custom Media Receiver
Android Client Application 
library dependencies 
• Minimum SDK version supported by Google Cast is 9 (Gingerbread) 
• MediaRouter API of android-support-v7 
• Google Play Services 
• AppCompat API of android-support-v7 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Android Client Application 
typical sender application flow 
• Sender app starts MediaRouter device discovery: MediaRouter.addCallback 
• MediaRouter informs sender app of the route the user selected: MediaRouter.Callback.onRouteSelected 
• Sender app retrieves CastDevice instance: CastDevice.getFromBundle 
• Sender app creates and uses GoogleApiClient: GoogleApiClient.Builder 
source: developers.google.com 
• Sender app launches the receiver app: Cast.CastApi.launchApplication 
• Sender app creates a communication channel: Cast.CastApi.setMessageReceivedCallbacks 
• Sender sends a message to the receiver over the communication channel: Cast.CastApi.sendMessage 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Cast-Ready Device Discovery 
capabilities 
Remote 
Playback 
Live 
Audio 
Live 
Video 
MediaRouteSelector.Builder mediaRouteSelectorBuilder = new MediaRouteSelector.Builder(); 
mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); 
mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO); 
mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO); 
MediaRouterSelector mediaRouterSelector = mediaRouterSelectorBuilder.build(); 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Media Cast Button 
easy approach for discovering 
source: developers.google.com source: developers.google.com 
public boolean onCreateOptionsMenu(Menu menu) { 
MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item); 
MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) 
MenuItemCompat.getActionProvider(mediaRouteMenuItem); 
mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector); …. } 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Receiver Application 
what a mistery? 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
What is? 
HTML5 and Javascript application 
What does it do? 
Display the media content on TV 
Message handling 
Which type? 
Default 
Media 
Receiver 
Styled 
Media 
Receiver 
Custom 
Media 
Receiver
Default Media Receiver 
simplest 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
• Off-the-shelf 
• No UI customization 
• No registration 
Source: developers.google.com
Styled Media Receiver 
simple and customizable 
• Similar to Default Media Player 
• CSS UI customization 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
• Registration 
Source: developers.google.com
Custom Media Receiver (1/3) 
whatever you want 
• Fully Web Applicaiton 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
• Debug(able) at 9222 
• Registration 
Source: developers.google.com
Custom Media Receiver (2/3) 
example 
<html> 
<head> 
<title>Example minimum receiver</title> 
<script src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script> 
</head> 
<body> 
<video id='media'/> 
<script> 
window.mediaElement = document.getElementById('media'); 
window.mediaManager = new cast.receiver.MediaManager(window.mediaElement); 
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance(); 
window.castReceiverManager.start(); 
</script> 
</body> 
</html> 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Custom Media Receiver (3/3) 
advanced features 
• Video Codification/Decodification 
• H.264 High Profile Level 4.1, 4.2 and 5 
• VP8 
• Adaptive Bitrate Streaming 
• HTTP Live Streaming (HLS) 
• Dynamic Adaptive Streaming over HTTP (MPEG-DASH) 
• Smooth Streaming 
• Digital Rights Management 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
• Play Ready DRM 
• Widevine DRM 
• Media Player Library
Channel, Namespace and Protocol (1/2) 
communication 
• Protocol: a set of well-known messages 
• Namespace: a labeled protocol 
• Channel: the communication layer 
class CustomChannel implements Cast.MessageReceivedCallback { 
public String getNamespace() { return “urn:x-cast:com.channel.custom”; } 
@Override 
public void onMessageReceiver(CastDevice castDevice, String namespace, String message) { … } 
} 
… 
Cast.CastApi.setMessageReceivedCallbacks(mApiClient, mCustomChannel.getNamespace(), 
mCustomChannel); 
… 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Channel, Namespace and Protocol (2/2) 
communication 
• Media Namespace: urn:x-cast:com.google.media.cast 
• RemoteMediaPlayer 
• MediaManager 
RECEIVER MEDIA CHANNEL 
window.mediaManager = new cast.receiver.MediaManager(window.mediaElement); 
… 
CLIENT MEDIA CHANNEL 
Cast.CastApi.setMessageReceivedCallbacks(mApiClient, 
mRemoteMediaPlayer.getNamespace(), mCustomChannel); 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 
…
Google Api Client and Media Route Provider 
manufacturing 
Source: developers.google.com 
CastDevice selectedCastDevice = CastDevice.getFromBundle(selectedRouteInfo.getExtras); 
Cast.CastOptions.Builder apiOptionsBuilder = new Cast.CastOptions.Builder(selectedCastDevice, …); 
googleApiClient = new GoogleApiClient.Builder().addApi(Cast.API, apiOptionsBuilder.build()).build(); 
googleApiClient.connect(); 
Cast.CastApi.launchApplication(googleApiClient, applicationId, launchOptions); 
Cast.CastApi.joinApplication(googleApiClient); 
Cast.CastApi.stopApplication(googleApiClient); 
Cast.CastApi.leaveApplication(googleApiClient); 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
RemoteMediaPlayer 
…finally 
MediaInfo mediaInfo = new MediaInfo.Builder("http://your.server.com/video.mp4") 
.setContentType("video/mp4") 
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) 
.setMetadata(mediaMetadata) 
.build(); 
… 
mRemoteMediaPlayer = new RemoteMediaPlayer(); 
mRemoteMediaPlayer.load(mApiClient, mediaInfo, true); 
… 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Enjoy the video 
Source: www.huffingtonpost.ca 
Thank you to all of you 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Resources 
• Android Mediaplayer-> http://developer.android.com/guide/topics/media/mediaplayer.html 
• ExoPlayer -> https://github.com/google/ExoPlayer 
• Google Cast -> https://developers.google.com/cast 
• Chromecast App -> http://www.google.it/chrome/devices/chromecast/apps.html 
• Google Cast Downloads -> https://developers.google.com/cast/docs/downloads 
• Github -> https://github.com/googlecast 
• Android TV -> https://developer.android.com/tv 
• Nvidia Guideline -> https://developer.nvidia.com/android-tv-developer-guide 
• Github -> https://github.com/googlesamples/androidtv-Leanback.git 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
Contacts 
+MatteoBonifazi 
m.bonifazi[at]reply.it 
@mbonifazi 
+AlessandroMartellucci 
a.martellucci[at]reply.it 
@martellux 
http://www.reply.eu http://www.gaiareply.com 
Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci

Mais conteúdo relacionado

Mais procurados

Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Ryan Baxter
 
Rubato Introduction
Rubato IntroductionRubato Introduction
Rubato Introduction
jdiloreto
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on Android
Xavier Hallade
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
Nicholas Jansma
 
Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)
LewisB2013
 
Android Programming Basic
Android Programming BasicAndroid Programming Basic
Android Programming Basic
Duy Do Phan
 

Mais procurados (20)

ExoPlayer for Application developers
ExoPlayer for Application developersExoPlayer for Application developers
ExoPlayer for Application developers
 
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
 
Rubato Introduction
Rubato IntroductionRubato Introduction
Rubato Introduction
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on Android
 
YouTube APIs presentation at Facultad de Ciencias, Universidad Nacional Autón...
YouTube APIs presentation at Facultad de Ciencias, Universidad Nacional Autón...YouTube APIs presentation at Facultad de Ciencias, Universidad Nacional Autón...
YouTube APIs presentation at Facultad de Ciencias, Universidad Nacional Autón...
 
Flash Builder and Flex Future - Multiscreen Development
Flash Builder and Flex Future - Multiscreen DevelopmentFlash Builder and Flex Future - Multiscreen Development
Flash Builder and Flex Future - Multiscreen Development
 
Building Video Applications with YouTube APIs
Building Video Applications with YouTube APIsBuilding Video Applications with YouTube APIs
Building Video Applications with YouTube APIs
 
Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012
 
YouTube APIs Workshop
YouTube APIs WorkshopYouTube APIs Workshop
YouTube APIs Workshop
 
Introduction of oesf education consortium
Introduction of oesf education consortiumIntroduction of oesf education consortium
Introduction of oesf education consortium
 
Android Application Development Basic
Android Application Development BasicAndroid Application Development Basic
Android Application Development Basic
 
Getting Android Developers for Your Wearables
Getting Android Developers for Your WearablesGetting Android Developers for Your Wearables
Getting Android Developers for Your Wearables
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
 
Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)Lewis brady engine_terminology (edited version)
Lewis brady engine_terminology (edited version)
 
Discovering the p2 API
Discovering the p2 APIDiscovering the p2 API
Discovering the p2 API
 
Google teams up with ubuntu to bring linux desktop app support to flutter
 Google teams up with ubuntu to bring linux desktop app support to flutter Google teams up with ubuntu to bring linux desktop app support to flutter
Google teams up with ubuntu to bring linux desktop app support to flutter
 
Stefano Fornari - Come creare e far crescere un progetto ed una community ope...
Stefano Fornari - Come creare e far crescere un progetto ed una community ope...Stefano Fornari - Come creare e far crescere un progetto ed una community ope...
Stefano Fornari - Come creare e far crescere un progetto ed una community ope...
 
Android Application WebAPI Development Training
Android Application WebAPI Development TrainingAndroid Application WebAPI Development Training
Android Application WebAPI Development Training
 
Cyworld AppStore Overview
Cyworld AppStore OverviewCyworld AppStore Overview
Cyworld AppStore Overview
 
Android Programming Basic
Android Programming BasicAndroid Programming Basic
Android Programming Basic
 

Destaque

Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
fefe7270
 
Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)
Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)
Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)
DataArt
 

Destaque (17)

IT talk #18 Odessa: Alexey Rybakov "Android TV"
IT talk #18 Odessa: Alexey Rybakov "Android TV"IT talk #18 Odessa: Alexey Rybakov "Android TV"
IT talk #18 Odessa: Alexey Rybakov "Android TV"
 
Video service
Video serviceVideo service
Video service
 
3D Video Programming for Android
3D Video Programming for Android3D Video Programming for Android
3D Video Programming for Android
 
Android tv get started
Android tv get startedAndroid tv get started
Android tv get started
 
CMAF 101 by Cyril Concolato
CMAF 101 by Cyril ConcolatoCMAF 101 by Cyril Concolato
CMAF 101 by Cyril Concolato
 
2016 Streaming Media West: Transitioning from Flash to HTML5
2016 Streaming Media West: Transitioning from Flash to HTML52016 Streaming Media West: Transitioning from Flash to HTML5
2016 Streaming Media West: Transitioning from Flash to HTML5
 
Embedded Android Real-Time Streaming Optimization
Embedded Android Real-Time Streaming OptimizationEmbedded Android Real-Time Streaming Optimization
Embedded Android Real-Time Streaming Optimization
 
2016 Streaming Media West: Choosing an HTML5 Player
2016 Streaming Media West: Choosing an HTML5 Player2016 Streaming Media West: Choosing an HTML5 Player
2016 Streaming Media West: Choosing an HTML5 Player
 
Best Practices in Media Playback
Best Practices in Media PlaybackBest Practices in Media Playback
Best Practices in Media Playback
 
Working with Android TV - English
Working with Android TV - EnglishWorking with Android TV - English
Working with Android TV - English
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
 
ABR Algorithms Explained (from Streaming Media East 2016)
ABR Algorithms Explained (from Streaming Media East 2016) ABR Algorithms Explained (from Streaming Media East 2016)
ABR Algorithms Explained (from Streaming Media East 2016)
 
用十分鐘學會 《微積分、工程數學》及其應用
用十分鐘學會  《微積分、工程數學》及其應用用十分鐘學會  《微積分、工程數學》及其應用
用十分鐘學會 《微積分、工程數學》及其應用
 
The next generation of protocols and APIs that could change streaming video
The next generation of protocols and APIs that could change streaming videoThe next generation of protocols and APIs that could change streaming video
The next generation of protocols and APIs that could change streaming video
 
Developing Android Apps for TV in Minutes with Amazon Fire App Builder
Developing Android Apps for TV in Minutes with Amazon Fire App BuilderDeveloping Android Apps for TV in Minutes with Amazon Fire App Builder
Developing Android Apps for TV in Minutes with Amazon Fire App Builder
 
Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)
Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)
Поговорим про Android TV, Алексей Рыбаков, Senior Mobile developer (DataArt)
 

Semelhante a Video Streaming: from the native Android player to uncoventional devices

Android before getting started
Android before getting startedAndroid before getting started
Android before getting started
Ahsanul Karim
 

Semelhante a Video Streaming: from the native Android player to uncoventional devices (20)

Basics of Android
Basics of Android Basics of Android
Basics of Android
 
Android Interview Questions
Android Interview QuestionsAndroid Interview Questions
Android Interview Questions
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
 
[Android Codefest] Using the Second-Screen API & Intel® Wireless Display From...
[Android Codefest] Using the Second-Screen API & Intel® Wireless Display From...[Android Codefest] Using the Second-Screen API & Intel® Wireless Display From...
[Android Codefest] Using the Second-Screen API & Intel® Wireless Display From...
 
Sogeti - Android tech track presentation - 24 february 2011
Sogeti - Android tech track presentation - 24 february 2011Sogeti - Android tech track presentation - 24 february 2011
Sogeti - Android tech track presentation - 24 february 2011
 
Android before getting started
Android before getting startedAndroid before getting started
Android before getting started
 
My android
My androidMy android
My android
 
My android
My androidMy android
My android
 
Rococo Software Overview Q3 2010
Rococo Software Overview Q3 2010Rococo Software Overview Q3 2010
Rococo Software Overview Q3 2010
 
AndroidFragmentation.com – an open community project
AndroidFragmentation.com – an open community project AndroidFragmentation.com – an open community project
AndroidFragmentation.com – an open community project
 
Liferay Italy Symposium 2015 Liferay Mobile SDK and Liferay Screens
Liferay Italy Symposium 2015 Liferay Mobile SDK and Liferay ScreensLiferay Italy Symposium 2015 Liferay Mobile SDK and Liferay Screens
Liferay Italy Symposium 2015 Liferay Mobile SDK and Liferay Screens
 
Android
AndroidAndroid
Android
 
Software training report
Software training reportSoftware training report
Software training report
 
Introduction to Android.ppt
Introduction to Android.pptIntroduction to Android.ppt
Introduction to Android.ppt
 
Webinar on How to use MyAppConverter
Webinar on How to use  MyAppConverterWebinar on How to use  MyAppConverter
Webinar on How to use MyAppConverter
 
Introduction to Android App Development
Introduction to Android App DevelopmentIntroduction to Android App Development
Introduction to Android App Development
 
Basic android
Basic androidBasic android
Basic android
 
001-Mobile Application.pptx
001-Mobile Application.pptx001-Mobile Application.pptx
001-Mobile Application.pptx
 
Android seminar report
Android seminar reportAndroid seminar report
Android seminar report
 
Android introduction
Android introductionAndroid introduction
Android introduction
 

Mais de Matteo Bonifazi

Mais de Matteo Bonifazi (16)

Invading the home screen
Invading the home screenInvading the home screen
Invading the home screen
 
Engage user with actions
Engage user with actionsEngage user with actions
Engage user with actions
 
Kotlin killed Java stars
Kotlin killed Java starsKotlin killed Java stars
Kotlin killed Java stars
 
Android JET Navigation
Android JET NavigationAndroid JET Navigation
Android JET Navigation
 
Firebase-ized your mobile app
Firebase-ized  your mobile appFirebase-ized  your mobile app
Firebase-ized your mobile app
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
 
Android - Saving data
Android - Saving dataAndroid - Saving data
Android - Saving data
 
Android Networking
Android NetworkingAndroid Networking
Android Networking
 
Android - Displaying images
Android - Displaying imagesAndroid - Displaying images
Android - Displaying images
 
Android - Background operation
Android - Background operationAndroid - Background operation
Android - Background operation
 
Android things intro
Android things introAndroid things intro
Android things intro
 
The Firebase tier for your mobile app - DevFest CH
The Firebase tier for your mobile app - DevFest CHThe Firebase tier for your mobile app - DevFest CH
The Firebase tier for your mobile app - DevFest CH
 
Engage and retain users in the android world - Droidcon Italy 2016
Engage and retain users in the android world - Droidcon Italy 2016Engage and retain users in the android world - Droidcon Italy 2016
Engage and retain users in the android world - Droidcon Italy 2016
 
UaMobitech - App Links and App Indexing API
UaMobitech - App Links and App Indexing APIUaMobitech - App Links and App Indexing API
UaMobitech - App Links and App Indexing API
 
Google IO - Five months later
Google IO - Five months laterGoogle IO - Five months later
Google IO - Five months later
 
Enlarge your screen
Enlarge your screenEnlarge your screen
Enlarge your screen
 

Último

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Último (6)

Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 
Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 

Video Streaming: from the native Android player to uncoventional devices

  • 1. Video Streaming from the native Android player to uncoventional devices Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 2. Open Reply & Android Lab • Reply is today a leading IT Services Company • Operates in Italy, Germany, UK, Benelux, USA and Brasil. • Open Reply is the company of Reply Group focused on open source software, multichannel web solutions and mobile applications. • Based in Rome, Open Reply’s Android Lab is a young team of over 20 engineers 100% focused on Android development. • We are specialised in broadcasting, banking and Android OS Customisation. Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 3. Presentation Millestones • Playing a content on your handheld device. • Entertaiment tailored for the user with • Easiest way to enjoy online video and music on user TV on Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 4. Android multimedia framework • Android support for playing several media types from media file stored inside the application (raw resources, standalone files) or for OTT streaming. • Documentation of the media framework is enough just for simple test case. • Underneath MediaPlayer Framework documentation is kind of nightmare (lot of events and error are not documented at all). Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 5. Supported type HttpLiveStreaming Protocol 3 is supported by Android 4.0. Best implementation is in Kitkat. Google seems putting all his efforts to support new media type ( SmoothStreaming, Dynamic adaptive streaming) Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 6. Playing a video Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci VideoView Three different approaches Mediaplayer & SurfaceView ExoPlayer
  • 7. MediaPlayer code example android.widget.VideoView //1. Find the view from the layout VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview); //2. Setup video url myVideoView.setVideoURI(Uri.parse(SrcPath)); //3. Setup Video controller myVideoView.setMediaController(new MediaController(this)); //4. Start playing myVideoView.requestFocus(); myVideoView.start(); Programmer doesn’t directly handle the MediaPlayer Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 8. MediaPlayer code example android.media.Mediaplayer //0. Get SurfaceView and its holder mPreview = (SurfaceView)findViewById(R.id.surfaceView); holder = mPreview.getHolder(); //1. Create MediaPlayer object: mp = new MediaPlayer(); //2. Add SurfaceHolder callback - Aware when SurfaceView is created holder.addCallback(new SurfaceHolder.Callback(){ .... @Override public void surfaceCreated(SurfaceHolder holder) { android.view.SurfaceView //3. Attach the surface to the player mp.setDisplay(holder); try { mp.setDataSource(filepath); //4. Prepare the Mediaplayer in sync or async mode ( prepareAsync() ) mp.prepare(); } catch (Exception e) {// Catch the exception} //5. Start the player mp.start(); }... }); & Application creates SurfaceView and MediaPlayer. More control on MediaPlayer state Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 9. MediaPlayer code example // 1. Instantiate the player. player = ExoPlayer.Factory.newInstance(RENDERER_COUNT); // 2. Construct renderers. ExoPlayer MediaCodecVideoTrackRenderer videoRenderer = … MediaCodecAudioTrackRenderer audioRenderer = ... // 3. Inject the renderers through prepare. player.prepare(videoRenderer, audioRenderer); // 4. Pass the surface to the video renderer. player.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface); // 5. Start playback. player.setPlayWhenReady(true); ... player.release(); // Release when everything is done! Pre-built player that can be extend. Implement features not currently supported in the normal mediaplayer. Droidcon London – 2014 – Matteo Bonifazi e Alessandro Martellucci
  • 10. What kind of Mediaplayer exist? Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci • Built-in players ü AwesomePlayer (default player selected) ü NuPlayer (Apple HLS) • Extra player factories can be registered • DIY mediaplayer ü Demuxing: android.media.mediaExtractor ü Decoding: android.media.MediaCodec ü Video rendering: android.media.MediaCodec ü Audio rendering: android.media.AudioTrack ü Implement the interface frameworks/av/include/media/MediaPlayerInterface.h
  • 11. Android TV Entertainment tailored for you Source:h)p://www.televisedrevolu4on.com/ Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 12. Nexus Player Source:h)p://www.televisedrevolu4on.com/ Asus device – 235 g 1.8GHz Quad Core, Intel® Atom™ Imagination PowerVR Series 6 Graphics 2D/3D Engine Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci 1GB RAM 8GB storage
  • 13. Android TV app features Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci • Android TV devices have Android Lollipop 5.0 on board. • Android TV has inside the same Android mul4media framework of normal devices. • Android TV app can be built on API 17 towards. • Based on Leanback Android Support library
  • 14. 10 feet experience Smartphone 5” 320 dp Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci TV Full HD 30” 320 dpi 10 feet 16 inches
  • 15. Manifest features Support landscape Portrait activity are forbidden Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 16. Manifest features No touch screen <uses-feature android:name="android.hardware.touchscreen" android:required="false"/> Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 17. Manifest features Limit sensor <uses-feature android:name="android.hardware.sensor.accelerometer” android:required="false" /> Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 18. Keep calm and lean back!! Provides built-in tailored for 10 feet experience Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 19. Leanback support library <uses-feature android:name="android.software.leanback" android:required="true" /> <application android:allowBackup="false” android:label="@string/app_name” android:theme="@style/Theme.Leanback" > <activity android:name="MainActivity” android:screenOrientation="landscape" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> </intent-filter> </activity> Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 20. Leanback support library Model View Presenter Model Presenter View Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 21. Leanback UI component BroswerFragment allows the developer “to create a primary layout for browsing categories and rows of media items [with a minimum of code]” Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 22. Leanback UI component DetailFragment Display information about the content that the user has selected Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 23. Chromecast a cast-ready device for multi-screen experience source: www.google.it Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 24. Chromecast hardware specifications source: www.pcworld.com Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 25. Chromecast components • Google Cast technology • Multi-Screen experiece • Google Cast SDK • Sender Application • Android app • iOS app • Chrome app • Receiver Application Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci • Default Media Receiver • Styled Media Receiver • Custom Media Receiver
  • 26. Android Client Application library dependencies • Minimum SDK version supported by Google Cast is 9 (Gingerbread) • MediaRouter API of android-support-v7 • Google Play Services • AppCompat API of android-support-v7 Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 27. Android Client Application typical sender application flow • Sender app starts MediaRouter device discovery: MediaRouter.addCallback • MediaRouter informs sender app of the route the user selected: MediaRouter.Callback.onRouteSelected • Sender app retrieves CastDevice instance: CastDevice.getFromBundle • Sender app creates and uses GoogleApiClient: GoogleApiClient.Builder source: developers.google.com • Sender app launches the receiver app: Cast.CastApi.launchApplication • Sender app creates a communication channel: Cast.CastApi.setMessageReceivedCallbacks • Sender sends a message to the receiver over the communication channel: Cast.CastApi.sendMessage Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 28. Cast-Ready Device Discovery capabilities Remote Playback Live Audio Live Video MediaRouteSelector.Builder mediaRouteSelectorBuilder = new MediaRouteSelector.Builder(); mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK); mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO); mediaRouteSelectorBuilder.addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO); MediaRouterSelector mediaRouterSelector = mediaRouterSelectorBuilder.build(); Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 29. Media Cast Button easy approach for discovering source: developers.google.com source: developers.google.com public boolean onCreateOptionsMenu(Menu menu) { MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item); MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem); mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector); …. } Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 30. Receiver Application what a mistery? Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci What is? HTML5 and Javascript application What does it do? Display the media content on TV Message handling Which type? Default Media Receiver Styled Media Receiver Custom Media Receiver
  • 31. Default Media Receiver simplest Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci • Off-the-shelf • No UI customization • No registration Source: developers.google.com
  • 32. Styled Media Receiver simple and customizable • Similar to Default Media Player • CSS UI customization Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci • Registration Source: developers.google.com
  • 33. Custom Media Receiver (1/3) whatever you want • Fully Web Applicaiton Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci • Debug(able) at 9222 • Registration Source: developers.google.com
  • 34. Custom Media Receiver (2/3) example <html> <head> <title>Example minimum receiver</title> <script src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script> </head> <body> <video id='media'/> <script> window.mediaElement = document.getElementById('media'); window.mediaManager = new cast.receiver.MediaManager(window.mediaElement); window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance(); window.castReceiverManager.start(); </script> </body> </html> Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 35. Custom Media Receiver (3/3) advanced features • Video Codification/Decodification • H.264 High Profile Level 4.1, 4.2 and 5 • VP8 • Adaptive Bitrate Streaming • HTTP Live Streaming (HLS) • Dynamic Adaptive Streaming over HTTP (MPEG-DASH) • Smooth Streaming • Digital Rights Management Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci • Play Ready DRM • Widevine DRM • Media Player Library
  • 36. Channel, Namespace and Protocol (1/2) communication • Protocol: a set of well-known messages • Namespace: a labeled protocol • Channel: the communication layer class CustomChannel implements Cast.MessageReceivedCallback { public String getNamespace() { return “urn:x-cast:com.channel.custom”; } @Override public void onMessageReceiver(CastDevice castDevice, String namespace, String message) { … } } … Cast.CastApi.setMessageReceivedCallbacks(mApiClient, mCustomChannel.getNamespace(), mCustomChannel); … Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 37. Channel, Namespace and Protocol (2/2) communication • Media Namespace: urn:x-cast:com.google.media.cast • RemoteMediaPlayer • MediaManager RECEIVER MEDIA CHANNEL window.mediaManager = new cast.receiver.MediaManager(window.mediaElement); … CLIENT MEDIA CHANNEL Cast.CastApi.setMessageReceivedCallbacks(mApiClient, mRemoteMediaPlayer.getNamespace(), mCustomChannel); Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci …
  • 38. Google Api Client and Media Route Provider manufacturing Source: developers.google.com CastDevice selectedCastDevice = CastDevice.getFromBundle(selectedRouteInfo.getExtras); Cast.CastOptions.Builder apiOptionsBuilder = new Cast.CastOptions.Builder(selectedCastDevice, …); googleApiClient = new GoogleApiClient.Builder().addApi(Cast.API, apiOptionsBuilder.build()).build(); googleApiClient.connect(); Cast.CastApi.launchApplication(googleApiClient, applicationId, launchOptions); Cast.CastApi.joinApplication(googleApiClient); Cast.CastApi.stopApplication(googleApiClient); Cast.CastApi.leaveApplication(googleApiClient); Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 39. RemoteMediaPlayer …finally MediaInfo mediaInfo = new MediaInfo.Builder("http://your.server.com/video.mp4") .setContentType("video/mp4") .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(mediaMetadata) .build(); … mRemoteMediaPlayer = new RemoteMediaPlayer(); mRemoteMediaPlayer.load(mApiClient, mediaInfo, true); … Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 40. Enjoy the video Source: www.huffingtonpost.ca Thank you to all of you Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 41. Resources • Android Mediaplayer-> http://developer.android.com/guide/topics/media/mediaplayer.html • ExoPlayer -> https://github.com/google/ExoPlayer • Google Cast -> https://developers.google.com/cast • Chromecast App -> http://www.google.it/chrome/devices/chromecast/apps.html • Google Cast Downloads -> https://developers.google.com/cast/docs/downloads • Github -> https://github.com/googlecast • Android TV -> https://developer.android.com/tv • Nvidia Guideline -> https://developer.nvidia.com/android-tv-developer-guide • Github -> https://github.com/googlesamples/androidtv-Leanback.git Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci
  • 42. Contacts +MatteoBonifazi m.bonifazi[at]reply.it @mbonifazi +AlessandroMartellucci a.martellucci[at]reply.it @martellux http://www.reply.eu http://www.gaiareply.com Droidcon London – 2014 – Matteo Bonifazi & Alessandro Martellucci

Notas do Editor

  1. android:screenOrientation can’t be portrait, reversePortrait, sensorPortrait, userPortrait or reverseLandscape.
  2. No touchescreen– TV control comes with DPAD. TouchScreen must not to be required since Google Play won’t filter.
  3. Limit Sensor– Make optional every uses features which are for not crucial operation.
  4. Before starting to develop the Android client application is important to have in mind which are the basic requirements. First of all there are few library dependencies and constraints you’ll need to care about. Number one: the minimum SDK version supported by Goole Cast technology is the 9 that is Gingerbread Number two: the Goole Cast client APIs are packaged into the android.support.v7.media package of Android Support Library revision 19 o later Number three: you’ll need to setup the Google Play Services library revision 4.2 or later Number four: you must import the AppCompat which provides basic UI elements like the MediaButton, useful for establish a connection to the Chromecast device
  5. Now let me show you what is the typical sender application flow because it’s also important to understand which are the steps the client runs in order to start and control a receiver application. During the development phase you’ll have to interact with several Java objects. So first of all: the sender application uses the MediaRouter object to discover all the cast-device available inside the local WiFi network. through its callback, the MediaRouter informs the sender application which of the available. From the RouteInfo object the sender application extracts the instance of the CastDevice object: the most important object inside the development lifecycle. This is the object which represents the hardware specification of the cast-ready device Once the sender application knows the cast device the user selected it makes use of Google Play Services APIs in order to launch the receiver application and to establish a communication channel where several messages are exhanged Only at the end of these steps you’ll be able to play any kind of content using the RemoteMediaPlayer object
  6. Now I would like to give you more details about the discovery phase. It’s important because, inside the same local WiFi network, many cast-ready devices could be connected, everyone with different capabilities. So the sender app must make a choice in order to select the capailities it needs for. The Google Cast SDK provides three main categories that the Chromecast is able to manage: REMOTE PLAYBACK LIVE AUDIO LIVE VIDEO REMOTE PLAYBACK category idendifies all the routes which present a remote media by playing content from URI. These routes take the responsability for fetching and rendering content on their own. The application doesn’t display any content on the screen of the device. Different are the cases of the LIVE AUDIO and LIVE VIDEO where the routes support live audio and live video streaming respectively from device to the destination. Theses routes are the easiest to use because the application renders the content locally on the screen of the device and the system streams it automatically to the destination. A destination that could be a local display or wireless display with support for mirroring or Android presentation. Further, in this slide you can see how it’s easy to set the requested capabilities for the Android client application, using the MediaRouteSelector object.
  7. On the other side we have the receiver application. What a mistery? What a mistery just because I’ve experienced a lot of questions and curiosity from many collegues of mine. They couldn’t imagine what the receiver application is and how it works. I realized it was often confusing and frustrating for Android developers to find out that the receiver application is just an HTML5 and Javascript web application. Exactly. Inside the Chromecast device what’s running is a custom version of Chrome web browser. This decision is the reason why the Chromecast became a successful product. Having a widespread and consolidated technology like Chrome web browser playing the role of the media player allowed the many developers to solve most of the known problem about video streaming and to mantain client and server technology respectively decoupled. So what does it do? First of all it displays the media content on the TV and further it provides an handler for the management of the messages exchanged between the client application and the recevier device. As we’ll see later there is a strong presence of messages flow starting from the client towards the receiver and vice versa. If you’ll start develpoing a Chromecast application you would choose one of the three available media receiver: a default media receiver, a styled media receiver and finally a custom media receiver. The Chromecast Receiver API provides different solutions based on what are your needs. And now i’m showing you them.
  8. The default media receiver is the simplest and easy to use. It’s a prebuilt reciever application, hosted into the Google Cloud Factory, and it’s designed for the streaming of audio and video contents. It doesn’t provide any UI customization as Styled and Custom one permits and further it doesn’t require any kind of registration as Styled and Custom needs to.
  9. The Styled Media Receiver, instead, represents the right choice if you need a ready-made application receiver for media playing with the possibility to customise some little UI elements. By publishing a simple CSS file, with specific CSS class names, it’s possible change the logo image, the progress bar logo, the title style and so no. Differenty from the previous Media Receiver, the default one, the styled media receiver requires the user to register the receiver application by simply fullfil a web form. This registration calls for a name and a URL referring to host where the CSS file is remoted.