Google Cast is a technology that enables users to send any form of content from their mobile devices to larger devices like television. It enables Android and iOS devices to cast video, audio or other type of content to cast-ready receivers.
Download the tutorial to know how a communication channel is established between the sender and the receiver. Making your devices Google cast ready will give it an added advantage over other devices and will attract more customers.
The tutorial includes an introduction to Google Cast, the Design check-list of Google cast, the requirement study of Google cast, developing an app using Google cast, technical details of Google cast and limitations of Google cast. The tutorial begins with the introduction section. It gives an introduction about Google cast as a technology and automatic session flushing of Google cast.
Following is a design section. It includes a check-list for the design of Google cast and pointers like cast base, cast button, cast menu, sender app, receiver app. The next section covers up the requirement section. It involves the requirements of Google cast in points like cast app, registering, paying a fee, Google Play library etc.
As a result comes the application development section. It talks about the ways to create an application using Google cast and steps like adding libraries, meta data elements, application theme, cast button and classes. It also talks about the types of receiver applications like style media receiver, custom receiver, and default media receiver. Then comes the section of technical details. It gives information about the technical details of Google cast like supported image format, streaming protocols, media player library supported etc.
The last section of the tutorial is about the limitations of Google cast. It includes limitation points like cast device is low-power, tabs/windows cannot be created, only one video element, video editing in any way is not supported.
4. Google Cast is a technology that enables multi-screen experiences
and lets a user send and control content like video from a small
computing devices like a phone, tablet or laptop to a large display
device liketelevision
Google Cast allows Android and iOS mobile apps and Chrome web
apps to “cast” content -like video, audio, and screen sharing
(mirroring) - to Cast-ready devices like a Chromecast
The Google Cast SDK was released on February 3, 2014
4
Google Cast
5. Whenevera query isrun
• Directly after a controller action completes, ifno exceptions are thrown
• Directly before a transaction is committed.
Example
def album=Album.get(1)
album.title ="Change It"
def otherAlbums =Album.findAllWhereTitleLike("%Change%")
assert otherAlbums.contains(album)
5
Automatic Session Flushing
6. 1.Cast Base:
Sender and Receiver both connected to same WiFi network.
There are two ways users can start a Cast session:
1. Connect & play: Connect to a Cast receiver before playing content
2. Play & connect: Connect to a Cast receiver while playing content
2.CastButton:
The cast button invokesa menu to connect, control and disconnect from
Cast receivers.
3.Cast Menu:
The devices menu isshown wheneverthe cast button ispressed. The cast
menu lets users connect, control and disconnect from Cast receivers.
6
Design Checklist
7. 4.SenderApp:
When content is casting / playing on a Cast receiver, the user must always
be able to control it from the sender app.
5.Receiver App:
The devices menu isshown wheneverthe cast button ispressed. The cast
menu lets users connect, control and disconnect from Cast receivers.
7
Design Checklist
8. 1.Minimum Android SDK version that the Cast SDK supports is 9
(GingerBread)
2.The Google Play services library need to be referenced inside the
application element.
3.Cast application development involves development of Sender and
Receiver applications.
4.You need to register your application in order to get application ID
(which will be used in both “sender” and “receiver” applications).
https://cast.google.com/publish/
5. Pay the one time $5 registration fee
6. Register your Google Cast device so that it may access your receiver
application before you publish it.
8
Requirements
9. 1.Create empty Android application and add the following libraries as
dependencies:
android-sdkextrasandroidsupportv7appcompat
android-sdkextrasandroidsupportv7mediarouter
android-sdkextrasgooglegoogle_play_serviceslibprojectgoogle-
play-services_lib
2.Meta-data elementis required in manifest:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
3.Application’s theme:
android:theme="@style/Theme.AppCompat"
9
Developing Sender App
11. Sender app starts MediaRouter device discovery: MediaRouter.addCallback
MediaRouter informs user selected: MediaRouter.Callback.onRouteSelected
Sender app retrieves CastDevice instance: CastDevice.getFromBundle
Sender app creates a GoogleApiClient: GoogleApiClient.Builder
Sender app connects the GoogleApiClient: GoogleApiClient.connect
SDK confirms: GoogleApiClient.ConnectionCallbacks.onConnected
Sender app launches the receiver app: Cast.CastApi.launchApplication
SDK confirms: ResultCallback<Cast.ApplicationConnectionResult>
Creates a communication channel:
Cast.CastApi.setMessageReceivedCallbacks
Sender sends a message to the receiver: Cast.CastApi.sendMessage
10
Sender application flow
12. “Receiver” application is a special form of Web application that can
run on a Chromecast device
Functions of Receiver Application:
1.Provides an interface to display the app's content.
2.Handles messages from the sender application to control content on
the receiver device.
3. Handles custom messages from the sender application that
are application-specific
12
Developing Receiver App
13. 1.Styled Media Receiver:
Pre-built receiver application hosted by Google that is designed for streaming
audio and video content
2.Custom Receiver:
Ifapp provides content such as a game or image gallery, requires DRM, or
requires support for media types. Itis an HTML5 app that you host on your own
servers using the JavaScript Receiver API.
3.Default Media Receiver:
Itdoes not require you to register with the Google Cast SDK Developer Console,
but you cannot customize any of the UI.
CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID
13
Types of Receiver Application
14. 1.Use same WiFi network for both sender and receiver device
2.Supported Image formats :BMP, GIF, JPEG, PNG,WEBP
3.Supported Audioformats: MP3, Vorbis, Wav
4.Streaming protocols: MP4,WebM
5.Media Player Library supported types: PlayReady, Widevine
6.Optimized android apps: Youtube, Netflix, Google Music, Google
Movies
7.Download the Google Cast Extension for Crome browser:
https://chrome.google.com/webstore/detail/google-cast/
14
Technical Details
15. 1.The Cast device is a low-power device with memory, CPU, and GPU
limitations, so the receiver application should be as lightweight as possible
2.Tabs, windows or popups cannot be created in the receiver app, and
there should be nothing on the receiver device screen requiring input. All
interaction with the application must be done through a sender application
3.Only one video element may be active at any time
4.Video compositing, manipulation, transformations, rotations or zooming are
not supported
15
Limitations