GUSTAVO MOREIRA: Do you want to get your iOS
apps on the big screen?
Well, we have made it easier than ever before.
Hi.
I'm Gustavo Moreira from the Google Developer Relations
team.
And I'm going to talk to you about the Google Cast SDK
version 3 for iOS.
In June in 2016, we launched a new version 3 API
for the Google Cast SDK.
That new Cast SDK simplifies several parts
of the previous Google Cast SDK and addresses the major pain
points identified by content partners and developers.
The new Cast SDK greatly reduces the amount
of code needed by providing UI widgets that
fully comply with the Cast UX design checklist.
First, here's some terminology about how Casting works.
The Google Cast sender application
refers to an app running on a mobile device or laptop.
And the receiver application refers to an HTML application
running on a Chromecast or any other Google Cast receiver
devices.
Let's take a quick look at the typical lifecycle
off a Cast sender app.
When the Cast sender app is launched,
Cast receiver devices need to be discovered
on the local network.
Once the user selects a device, the sender app
will connect to that device and launch the receiver app.
The sender app then creates a message channel
to the receiver app to send and receive messages.
The user can also disconnect from that device at any time.
The new SDK implements these new features.
UI widgets that comply with the Google Cast design checklist,
notification and lock screen controls,
automatic device discovery, so you
don't have to manage that in your code,
centralized cast session state management,
and a reconnection service that automatically handles
network issues to keep your sender app
connected to the receiver.
Even when a user leaves their room
and goes out of the range of the network,
the session will be automatically reconnected
when the user returns.
To get your hands on the new SDK,
you just need to install the Google Cast SDK version 3
or higher from cocoapods.
Make sure to use iOS 8.0 as the deployment platform.
Let's take a look at how to add Cast to your app.
The Cast framework has a global singleton object, the GCK Cast
context, which coordinates all the cast interactions.
You must create a Cast options object to initialize
to Cast context singleton.
The most important option is the receiver application ID,
which you get from the Google Cast Developer Console.
You can then get the Cast context instance
by using the static shared instance method.
You can also set a default logger
to the logger shared instance.
For your app's UI, the first step in supporting Cast
is to add the Cast button.
The SDK provides a Cast button widget
that automatically manages its visibility and state,
and provides all the necessary dialogs for user
to select and disconnect devices.
The Cast button UI is a UI button
that can be added to the Navigation bar
as a ride bar button item.
Just initialize the Cast button with the proper size,
and add it to the Navigation bar.
When a user selects a Cast device using the Cast button
menu, a new Cast session is started automatically
by the framework.
All these interactions, including
backing out of this menu, are handled by the widget.
The list of devices is filtered based
on the app ID configuration in the Google Cast Developer
Console.
For the Cast framework, a Cast session
encapsulates the connection to a device,
managing the receiver application,
and initializing a media control channel for the media apps.
Cast sessions are managed by the session manager, which
can be accessed via the session manager property
on the Cast context object.
The GCK session manager listener callbacks
can be used to monitor session events such as creation,
suspension, resumption, and termination.
To play media on the receiver, the sender app
has to the media metadata of the media stream.
Here you can see how it just add the media type, title,
and images using the media metadata class.
And here you can see how it just add the media URL, string type,
and other metadata using the media information class.
The remote media client class is then
used to load a media stream on the receiver.
The sender app then invokes commands such as play and pause
using the remote media client.
The sender app can use the session manager listener
callbacks to track the session estate,
and decide when to enable and disable the local media player.
As required by the Cast UX guidelines,
the SDK provides a widget called the mini controller that
appears when the user navigates away from the current content
page to another part of the app.
The mini controller provides instant access
to playback controls and a visible reminder
for the current Cast session.
The Cast SDK provides a custom field
UI mini controls view controller, which
can be created from the Cast context object
and added to any container view in your app.
The Google Cast design checklist also
requires a sender app to provide an expanded controller
for the media being cast.
The expanded controller is a full screen version
of the MIDI controller.
The Cast SDK provides a widget for the expanded controller
that can be presented directly from the Cast context object.
To add an expanded controller, just enable it
in the Act Delegate Affair app.
In the Did Finish Launching with Options method,
just enable the default expanded media controls off
the SDK in the Cast context object.
The Cast SDK provides a custom view
called Call Cast Instructions View Controller that
can be used to highlight a Cast button when it's first
shown to users.
This code shows how you can use the Cast Context Present Cast
Instructions View Controller Once method
to show the overlay in your app only the first time
the user accesses it.
That's everything you need to Cast enable your app.
You can get more details about the Google Cast SDK
at developers.Google.com/cast.
We have also open source sample Cast apps that you
can use as a reference.
And if you have any developer questions,
pose those on the Stack Overflow.
Join our Google Cast developers community on G+ to keep up
to date with SDK updates and to chat with other developers
and share ideas.
Thanks for watching, and see you next time.
[MUSIC PLAYING]