The document discusses various approaches for playing videos on Android, including built-in players like VideoView and MediaPlayer, and third party players like ExoPlayer. It also covers streaming video to different devices like Android TV and Chromecast using technologies like the Leanback library, Google Cast SDK, and implementing custom receiver applications. Specific code examples and considerations for developing video applications on Android TV and with Chromecast are provided.
The unconventional devices for the Android video streamingMatteo Bonifazi
Streaming video is not just through Android smartphone and tablet.
The 2014 was the year where Chromecast reached its brightness, getting into 4 millions living rooms. The 2015 instead is the year of the Android TV, the Google way “to smart” the TV.
This talk we’ll give you an overview about the streaming in Android. Starting from video streaming on mobile devices, we will guide you into the evolution of the development through Chromecast up to Android TV.
Matteo Bonifazi and Alessandro Martellucci will be illustrating this talk with their experiences developing mobile television applications for the main Italian broadcaster providers.
Streaming video is not just through Android smartphone and tablet.
The 2014 was the year where Chromecast reached its brightness, getting into 4 millions living rooms. The 2015 instead is the year of the Android TV, the Google way “to smart” the TV.
This talk we’ll give you an overview about the streaming in Android. Starting from video streaming on mobile devices, we will guide you into the evolution of the development through Chromecast up to Android TV.
Matteo Bonifazi and Alessandro Martellucci will be illustrating this talk with their experiences developing mobile television applications for the main Italian broadcaster providers.
Video Streaming: from the native Android player to unconventional devicesAlessandro Martellucci
Getting a streaming video in your Android smartphone or tablet is no longer enough.In the latest period, Google shows how to push this concept forward to new appliances. Chromecast and Android TV are two of the most promising gadgets for upsetting the way users enjoy video streaming.
This talk we’ll give you an overview about the streaming in Android. Starting from video streaming on mobile devices, we will guide you into the evolution of the development through Chromecast up to Android TV. Matteo Bonifazi and Alessandro Martellucci will be illustrating this talk with their experiences developing mobile television applications for the main Italian broadcaster providers.
[Ultracode Munich Meetup #7] Building Apps for Nexus Player & Android TVBeMyApp
Slides by Mihai Risca, Software Application Engineer at Intel at the Ultracode Munich Meetup #7 @ Werk1 Munich
http://www.meetup.com/Ultracode-Munich/events/219689131/
[Android Codefest Germany] Adding x86 target to your Android app by Xavier Ha...BeMyApp
The Android Codefest Germany is a challenge on optimizing your existing Android NDK app on x86 processor or on building one.
It's still open until Sunday, November 24th, you can submit your app here: http://androidcodefest.bemyapp.com
The unconventional devices for the Android video streamingMatteo Bonifazi
Streaming video is not just through Android smartphone and tablet.
The 2014 was the year where Chromecast reached its brightness, getting into 4 millions living rooms. The 2015 instead is the year of the Android TV, the Google way “to smart” the TV.
This talk we’ll give you an overview about the streaming in Android. Starting from video streaming on mobile devices, we will guide you into the evolution of the development through Chromecast up to Android TV.
Matteo Bonifazi and Alessandro Martellucci will be illustrating this talk with their experiences developing mobile television applications for the main Italian broadcaster providers.
Streaming video is not just through Android smartphone and tablet.
The 2014 was the year where Chromecast reached its brightness, getting into 4 millions living rooms. The 2015 instead is the year of the Android TV, the Google way “to smart” the TV.
This talk we’ll give you an overview about the streaming in Android. Starting from video streaming on mobile devices, we will guide you into the evolution of the development through Chromecast up to Android TV.
Matteo Bonifazi and Alessandro Martellucci will be illustrating this talk with their experiences developing mobile television applications for the main Italian broadcaster providers.
Video Streaming: from the native Android player to unconventional devicesAlessandro Martellucci
Getting a streaming video in your Android smartphone or tablet is no longer enough.In the latest period, Google shows how to push this concept forward to new appliances. Chromecast and Android TV are two of the most promising gadgets for upsetting the way users enjoy video streaming.
This talk we’ll give you an overview about the streaming in Android. Starting from video streaming on mobile devices, we will guide you into the evolution of the development through Chromecast up to Android TV. Matteo Bonifazi and Alessandro Martellucci will be illustrating this talk with their experiences developing mobile television applications for the main Italian broadcaster providers.
[Ultracode Munich Meetup #7] Building Apps for Nexus Player & Android TVBeMyApp
Slides by Mihai Risca, Software Application Engineer at Intel at the Ultracode Munich Meetup #7 @ Werk1 Munich
http://www.meetup.com/Ultracode-Munich/events/219689131/
[Android Codefest Germany] Adding x86 target to your Android app by Xavier Ha...BeMyApp
The Android Codefest Germany is a challenge on optimizing your existing Android NDK app on x86 processor or on building one.
It's still open until Sunday, November 24th, you can submit your app here: http://androidcodefest.bemyapp.com
ExoPlayer is an open source, application level media player built on top of Android’s low level media APIs (Mediacodec and MediaExtractor). Google is already using it for Youtube and Movies app. It supports DASH, Smooth Streaming and HLS protocols.
Flash Builder and Flex Future - Multiscreen DevelopmentRyan Stewart
Mobile development on the Flash Platform. Flex and Flash Builder have some mobile-specific technology and paradigms that make it easy to create cross-vendor, cross-os mobile applications.
YouTube today is much more than a site. Using Google Data APIs and YouTube Player APIs, developers can harness the power of world’s most popular video destination to build new and innovative applications.
OESF Education Consortium is an organization promotes global Android engineer education. This presentation shows what OESF Education Consortium is, and how you can become our partner.
OESF Authorized Training Course official textbook
Course: Android Application Development Basic
FULL VERSION
Language: English
Contributed by
Created by: UL Systems Inc.
Edited by: Leading Edge Co.,Ltd.
Translated by: ISB Vietnam Co.,Ltd.
[Attention!]
This textbook is licensed under the Creative Commons License BY-NC-SA 4.0. It is prohibited to use this material for commercial use otherwise you are OESF member or OESF education consortium member.
Stefano Fornari - Come creare e far crescere un progetto ed una community ope...Better Software
Creare un software open source è molto di più che rendere scaricabile del codice sorgente. E' creare e alimentare una comunità fatta di utenti prima che di sviluppatori, che assieme contribuiscono a far progredire il prodotto innescando un circolo virtuoso tra le esigenze della comunità e quelle di un'azienda commerciale.
Android Application WebAPI Development TrainingOESF Education
OESF Authorized Training Course official textbook
Course: Android Application WebAPI Development Training
FULL VERSION
Language: English
Contributed by
Created by: Leading Edge Co.,Ltd.
Translated by: ISB Vietnam Co.,Ltd.
[Attention!]
This textbook is licensed under the Creative Commons License BY-NC-SA 4.0. It is prohibited to use this material for commercial use otherwise you are OESF member or OESF education consortium member.
IT talk #18 Odessa: Alexey Rybakov "Android TV"Marina Peregud
Алексей Рыбаков приехал из Харькова и провел IT talk #18. Поговорили в основном про телевидение на базе Android, нюансы разработки. Сравнили Android TV со схожими продуктами Apple, Sony и Mozzila. Алексей также раскрыл недостатки продукта и поделился презентацией.
ExoPlayer is an open source, application level media player built on top of Android’s low level media APIs (Mediacodec and MediaExtractor). Google is already using it for Youtube and Movies app. It supports DASH, Smooth Streaming and HLS protocols.
Flash Builder and Flex Future - Multiscreen DevelopmentRyan Stewart
Mobile development on the Flash Platform. Flex and Flash Builder have some mobile-specific technology and paradigms that make it easy to create cross-vendor, cross-os mobile applications.
YouTube today is much more than a site. Using Google Data APIs and YouTube Player APIs, developers can harness the power of world’s most popular video destination to build new and innovative applications.
OESF Education Consortium is an organization promotes global Android engineer education. This presentation shows what OESF Education Consortium is, and how you can become our partner.
OESF Authorized Training Course official textbook
Course: Android Application Development Basic
FULL VERSION
Language: English
Contributed by
Created by: UL Systems Inc.
Edited by: Leading Edge Co.,Ltd.
Translated by: ISB Vietnam Co.,Ltd.
[Attention!]
This textbook is licensed under the Creative Commons License BY-NC-SA 4.0. It is prohibited to use this material for commercial use otherwise you are OESF member or OESF education consortium member.
Stefano Fornari - Come creare e far crescere un progetto ed una community ope...Better Software
Creare un software open source è molto di più che rendere scaricabile del codice sorgente. E' creare e alimentare una comunità fatta di utenti prima che di sviluppatori, che assieme contribuiscono a far progredire il prodotto innescando un circolo virtuoso tra le esigenze della comunità e quelle di un'azienda commerciale.
Android Application WebAPI Development TrainingOESF Education
OESF Authorized Training Course official textbook
Course: Android Application WebAPI Development Training
FULL VERSION
Language: English
Contributed by
Created by: Leading Edge Co.,Ltd.
Translated by: ISB Vietnam Co.,Ltd.
[Attention!]
This textbook is licensed under the Creative Commons License BY-NC-SA 4.0. It is prohibited to use this material for commercial use otherwise you are OESF member or OESF education consortium member.
IT talk #18 Odessa: Alexey Rybakov "Android TV"Marina Peregud
Алексей Рыбаков приехал из Харькова и провел IT talk #18. Поговорили в основном про телевидение на базе Android, нюансы разработки. Сравнили Android TV со схожими продуктами Apple, Sony и Mozzila. Алексей также раскрыл недостатки продукта и поделился презентацией.
2016 Streaming Media West: Transitioning from Flash to HTML5Erica Beavers
As Flash continues to decline, HTML5 video technologies increasingly bring the promise of heightened performance and better QOE. This workshop provides an in-depth look at HTML5 players, their features and strengths, as well as the open-source media engine frameworks available on the market today. We begin by examining the main components in a video player, then discuss how to choose a player adapted to one’s use case, examining how several open-source solutions compare. Finally, we use an interactive example to build features and demonstrate several optimizations, offering tips and best practices and pointing out potential production issues as we go along.
This presentation given by Zhaolin Wang, VIA Embedded Software Manager, provides an overview of the Android multimedia framework and then moves on to tackle critical areas such as enabling full support for RTSP and HTTP protocols, and optimizing the Android multimedia framework to match streaming server parameters, as well as shortening processing time (from start to initial playback) to ensure smooth playback, how to solve problems of clock drift (out of sync audio and video), and improving fault tolerance to avoid crashes and freezes due to corrupt data.
2016 Streaming Media West: Choosing an HTML5 PlayerErica Beavers
This presentation provides a brief overview of how modern video players work, what broadcasters should look for depending on their technical and business goals, and different open-source tools that are available. It will discuss compatible formats, codecs and supported DRMs, user performance, the ability of each media engine to handle edge cases, and the performance of the ABR algorithms. At the end of the presentation, broadcasters will better understand what tools are right for their needs and be able to evaluate the pros and cons of each solution available.
Google I/O Extended Seoul 2016 발표자료입니다.
The ExoPlayer provides many sophisticated features such as Dynamic adaptive streaming over HTTP (DASH), SmoothStreaming and Common Encryption
ABR Algorithms Explained (from Streaming Media East 2016) Erica Beavers
Adaptive bitrate algorithms have become paramount in ensuring quality video delivery on every device and across varying network conditions. This presentation looks at the design goals and the inner workings of ABR logic, how it is used in the open-source players hls.js and dash.js, and what broadcasters can do to improve and optimize their own stack.
The next generation of protocols and APIs that could change streaming videoErica Beavers
As HTML5 video gains widespread adoption, we have seen significant advances in a short period of time. While EME and webRTC get a lot of attention, they are not the only tools with the potential to change the way we stream video in the future. In this presentation, we discuss some of the new browser APIs that could usher in the next generation of HTML5 video: from the browser Fetch API to Service Workers to network side improvements such as HTTP2 and QUIC. This presentation first discusses what these new APIs can do, as well as the advantages and possible drawbacks of using them. We then examine the state of the art and obstacles to adoption (standardization, politics, etc.) to offer broadcasters a glimpse of what the future will hold.
In this workshop we see how easy is to develop a native Android app for TV using Amazon Fire App Builder and how to connect to a media streaming service using media feeds.
Sogeti - Android tech track presentation - 24 february 2011Kenneth van Rumste
Presentation of the Android Tech Track by Sogeti.
Presentation by:
* Ben Stroobants
* Kenneth Van Rumste
* Mark Fonteyne
* Mikhail Panshenskov
* Alexis Mathieux
* Geoffroy Mispelaere
* Tom Pluym
AndroidFragmentation.com – an open community project Joachim Ritter
This presentation is about an open community project called AndroidFragmentation.com which aims at becoming a central imformation hub for specific fragmentation related device information.
Liferay Italy Symposium 2015 Liferay Mobile SDK and Liferay ScreensDenis Signoretto
Liferay Italy Symposium 2015 Liferay Mobile SDK and Liferay Screens, Building and Android App with Liferay (Using Liferay as Mobile Backend and Screens for reusable mobile compoents)
Introduction to Android App DevelopmentTodd Burgess
Presentation for Podcamp 2017 Toronto introducing how to do Android app development in Java. This is a basic introduction to what app development looks like Java and how to learn more
How much is your home screen useful with just icons? Not so much...Deep dive how to differentiate the home screen in order to increases user engagement, decreases the chance that an app will be uninstalled and increases the likelihood of its being used...
Deck was presented in Droidcon NYC 19 #DCNYC19
One important way we measure an Action's success is user engagement, or how effective the Action is at bringing users back after their first interaction. To help make this easier, there are several features you can implement in your Action that give users paths back into your conversation. In this talk covers user engagement features and best practices for Actions on Google
Change the way you navigate inside your Android mobile app. Let's see together how the new navigation architecture component can simplify the implementation of navigation in your app.
If you like or not, nowadays Firebase is an important milestone in the development of mobile applications and you can't avoid it.This deck is based on a true story!
Engage and retain users in the android world - Droidcon Italy 2016Matteo Bonifazi
Making your app engaging, so that users who have installed it actually use it, is crucial to your app’s success. In this speech, we explore a number of Android and Google features you can take advantage of that help make your app a more useful and embedded part of the user’s Android experience.
How to bring your app out from the dust on the web thanks to App Links and App Indexing API. How to acquire new users for you mobile app and to re-engage existing ones thanks to Google Search.
What is the real state of the new features, appliance and general news shown in the last Google IO ? What is up whats is down about the new Google technologies...
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
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
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
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
android:screenOrientation can’t be portrait, reversePortrait, sensorPortrait, userPortrait or reverseLandscape.
No touchescreen– TV control comes with DPAD. TouchScreen must not to be required since Google Play won’t filter.
Limit Sensor– Make optional every uses features which are for not crucial operation.
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
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
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.
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.
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.
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.