This codelab will teach you how to modify an existing iOS video app to play content on a Google Cast device.
InterContinental Hotels Group app and IHG® Rewards Club is available on the App Store and Google Play Store. The FREE IHG® app gives you immediate access to the entire IHG® Rewards Club Family of Brands including InterContinental, Crowne Plaza, Hotel Indigo, Holiday Inn, Holiday Inn Express, Staybridge Suites and Candlewood Suites. RecordIt is a tiny app for Mac that lets you record your screen and even have it converted into GIFs. Once you have installed the app, it sits in your status bar and you’re just a click away to start the recording. The preferences panel in the app lets you define some settings for the screencasts that you make. Step 2 Enable the Cast Tile Once installed, open the app and select the hamburger menu in the upper-left corner, then choose 'Multimedia'. You will be presented with a list of media-centric tiles that you can add to your Quick Settings. Select 'Cast' and choose 'Enable toggle,' then tap 'OK' on the popup to activate the tile.
Open a Chromecast-enabled app. Tap the Cast button. Note: The Cast button isn't located in the same place on all Chromecast-enabled apps. Tap the device to which you'd like to cast. Mobile to PC Screen Mirroring/Sharing app helps user to share their Android mobile screen to either windows PC or Laptop or MAC book. This App also provides option to launch cast screen option in their miracast enabled mobile phones to mirror their screens on to miracast enabled Smart TVs and dongles such as Chrome cast, Ezcast and other miracast enabled dongles.
What is Google Cast?
Google Cast allows users to cast content from a mobile device to a TV. Users can then use their mobile device as a remote control for media playback on the TV. Stop mac app installing.
The Google Cast SDK lets you extend your app to control Google Cast enabled devices (e.g. a TV or sound system). The Cast SDK allows you to add the necessary UI components based on the Google Cast Design Checklist.
The Google Cast Design Checklist is provided to make the Cast user experience simple and predictable across all supported platforms.
What are we going to be building?
When you have completed this codelab, you will have an iOS video app that will be able to Cast videos to a Google Cast device.
What you'll learn
- How to add the Google Cast SDK to a sample video app.
- How to add the Cast button for selecting a Google Cast device.
- How to connect to a Cast device and launch a media receiver.
- How to cast a video.
- How to add a Cast mini controller to your app.
- How to add an expanded controller.
- How to provide an introductory overlay.
- How to customize Cast widgets.
What you'll need
- The latest Xcode.
- One mobile device with iOS 9 or later (or the Xcode Simulator).
- A USB data cable to connect your mobile device to your development computer (if using a device).
- A Google Cast device such as a Chromecast or Android TV configured with internet access.
- A TV or monitor with HDMI input.
Android?
The Google Cast SDK is also supported on Android Jelly Bean (SDK level 16) or later. See the Android codelab about converting an Android video app to be Cast-enabled.
Experience
- You will need to have previous iOS development knowledge.
- You will also need previous knowledge of watching TV :)
Having networking issues?
If you are in a location where the WiFi network isn't reliable, then the Chromecast device can be wired by using an ethernet adapter. The Xcode simulator can also be used to run the app on your desktop and will be able to cast content. Also, see our user guide on Cast router compatibility.
How will you use this tutorial?
How would you rate your experience with building iOS apps?
How would you rate your experience with watching TV?
You can either download all the sample code to your computer.
and unpack the downloaded zip file.
The cast-videos-ios codelab contains two sample projects:
- app-start—The starting code that you'll build upon in this codelab.
- app-done—The complete code for the finished sample video app.
First, let's see what the completed sample app looks like. The app is a basic video player. The user can select a video from a list and can then play the video locally on the device or Cast it to a Google Cast device.
With the code downloaded, the following instructions describe how to open and run the completed sample app in Xcode:
Frequently asked questions
CocoaPods setup
Cocoapods: The recommended way of integrating Google Cast is using the google-cast-sdk Cocoapod and following its setup instructions outlined in this guide. If you would like to setup the dependencies manually, follow the manual setup guide outlined on the developer site. Kodi movie app for mac.
To setup CocoaPods, go to your console and install using the default Ruby available on macOS:
How can i set an app trusted on mac. Browse through the app page, and click on the iOS download tab. MDM is a safe method and requires no interaction at your end.Here are the steps to manually install an app on iPhone –. . Tap 'Install' on the next screen and wait until the custom app gets downloaded in your iPhone. Click on the 'Open' option when prompted with 'Open this page in 'iTunes'?'
If you have any issues, refer to the official documentation to download and install the dependency manager.
Project setup
- Go to your terminal and navigate to the codelab directory.
- Install the dependencies from the Podfile.
- Open Xcode and select Open another project.
- Select the
CastVideos-ios.xcworkspace
file from theapp-done
directory in the sample code folder.
Run the app
Select the target and simulator, and then run the app:
You should see the video app appear after a few seconds.
Be sure to click ‘Allow' when the notification appears about accepting incoming network connects. The Cast icon will not appear if this option is not accepted.
Click the Cast button and select your Google Cast device.
Select a video, click on the play button.
The video will start playing on your Google Cast device.
The expanded controller will be displayed. You can use the play/pause button to control the playback.
Navigate back to the list of videos.
A mini controller is now visible at the bottom of the screen.
Click on the pause button in the mini controller to pause the video on the receiver. Click on the play button in the mini controller to continue playing the video again.
Click on the Cast button to stop casting to the Google Cast device. Google sheets for mac.
We need to add support for Google Cast to the start app you downloaded. Here are some Google Cast terminology that we will be using in this codelab:
- a sender app runs on a mobile device or laptop,
- a receiver app runs on the Google Cast device.
Project setup
Now you're ready to build on top of the starter project using Xcode:
- Go to your terminal and navigate to the codelab directory.
- Install the dependencies from the Podfile.
- Open Xcode and select Open another project.
- Select the
CastVideos-ios.xcworkspace
file from theapp-start
directory in the sample code folder.
Note: The project is able to build, but will not run until the ‘Adding the Cast button' section is completed.
App design
The app fetches a list of videos from a remote web server and provides a list for the user to browse. Users can select a video to see the details or play the video locally on the mobile device.
The app consists of two main view controllers:
MediaTableViewController
and MediaViewController.
MediaTableViewController
This UITableViewController displays a list of videos from a
MediaListModel
instance. The list of videos and their associated metadata are hosted on a remote server as a JSON file. MediaListModel
fetches this JSON and processes it to build a list of MediaItem
objects.A
MediaItem
object models a video and its associated metadata, such as its title, description, URL for an image, and URL for the stream.MediaTableViewController
creates a MediaListModel
instance and then registers itself as a MediaListModelDelegate
to be informed when the media metadata has been downloaded so it can load the table view.The user is presented with a list of video thumbnails with a short description for each video. When an item is selected, the corresponding
MediaItem
is passed to the MediaViewController
.MediaViewController
This view controller displays the metadata about a particular video and allows the user to play the video locally on the mobile device.
The view controller hosts a
LocalPlayerView
, some media controls, and a text area to show the description of the selected video. The player covers the top portion of the screen, leaving room for the detailed description of the video beneath The user can play/pause or seek the local video playback.Cast documentation?
We have extensive documentation for iOS, Android and Chrome senders.
Frequently asked questions
![Mac cast enabled app tv Mac cast enabled app tv](/uploads/1/3/3/8/133879158/373867491.png)
A Cast-enabled application displays the Cast button in each of its view controllers. Clicking on the Cast button displays a list of Cast devices which a user can select. If the user was playing content locally on the sender device, selecting a Cast device starts or resumes playback on that Cast device. At any time during a Cast session, the user can click on the Cast button and stop casting your application to the Cast device. The user must be able to connect to or disconnect from the Cast device while in any screen of your application, as described in the Google Cast Design Checklist.
Configuration
The start project requires the same dependencies and Xcode setup as you did for the completed sample app. Return to that section and follow the same steps to add the
GoogleCast.framework
to the start app project.Initialization
The Cast framework has a global singleton object, the
GCKCastContext
, which coordinates all of the framework's activities. This object must be initialized early in the application's lifecycle, typically in the application(_:didFinishLaunchingWithOptions:)
method of the app delegate, so that automatic session resumption on the sender application restart can trigger properly and scanning for devices can start.A
GCKCastOptions
object must be supplied when initializing the GCKCastContext
. This class contains options that affect the behavior of the framework. The most important of these is the receiver application ID, which is used to filter Cast device discovery results and to launch the receiver application when a Cast session is started.The
application(_:didFinishLaunchingWithOptions:)
method is also a good place to set up a logging delegate to receive the logging messages from Cast framework. These can be useful for debugging and troubleshooting.When you develop your own Cast-enabled app, you have to register as a Cast developer and then obtain an application ID for your app. For this codelab, we will be using a sample app ID.
How do I become a Cast developer?
By registering with the Google Cast Developer Console, you can obtain an application ID for your app.
Add the following code to
AppDelegate.swift
to initialize GCKCastContext
with the application ID from the user defaults, and add a logger for the Google Cast framework:Cast button
Now that the
GCKCastContext
is initialized, we need to add the Cast button to allow the user to select a Cast device. The Cast SDK provides a Cast button component called GCKUICastButton
as a UIButton
subclass. It can be added to the application's title bar by wrapping it in a UIBarButtonItem
. We need to add the Cast button to both the MediaTableViewController
and the MediaViewController
.Add the following code to
MediaTableViewController.swift
and MediaViewController.swift
:Remember, when you incorporate cast into your own project, you need to repeat these steps to add the Cast button in ALL view controllers.
Now run the app. You should see a Cast button in the app's navigation bar and when you click on it, it will list the Cast devices on your local network. Device discovery is managed automatically by the
GCKCastContext
. Select your Cast device and the sample receiver app will load on the Cast device. You can navigate between the browse activity and the local player activity and the Cast button state is kept in sync.We haven't hooked up any support for media playback, so you can't play videos on the Cast device yet. Click on the Cast button to stop casting.
We will extend the sample app to also play videos remotely on a Cast device. To do that we need to listen to the various events generated by the Cast framework.
Casting media
At a high level, if you want to play a media on a Cast device, the following needs to happen:
- Create a
GCKMediaInformation
object from the Cast SDK that models a media item. - The user connects to the Cast device to launch your receiver application.
- Load the
GCKMediaInformation
object into your receiver and play the content. - Track the media status.
- Send playback commands to the receiver based on user interactions.
Step 1 amounts to mapping one object to another;
GCKMediaInformation
is something that the Cast SDK understands and MediaItem
is our app's encapsulation for a media item; we can easily map a MediaItem
to a GCKMediaInformation
. We have already done the Step 2 in the previous section. Step 3 is easy to do with the Cast SDK.The sample app
MediaViewController
already distinguishes between local vs remote playback by using this enum:It's not important in this codelab for you to understand exactly how all the sample player logic works. It is important to understand that your app's media player will have to be modified to be aware of the two playback locations in a similar way.
At the moment the local player is always in the local playback state since it doesn't know anything about the Casting states yet. We need to update the UI based on state transitions that happen in the Cast framework. For example, if we start casting, we need to stop the local playback and disable some controls. Similarly, if we stop casting when we are in this view controller, we need to transition to local playback. To handle that we need to listen to the various events generated by the Cast framework.
Cast session management
For the Cast framework a Cast session combines the steps of connecting to a device, launching (or joining), connecting to a receiver application, and initializing a media control channel if appropriate. The media control channel is how the Cast framework sends and receives messages from the receiver media player.
The Cast session will be started automatically when user selects a device from the Cast button, and will be stopped automatically when user disconnects. Reconnecting to a receiver session due to networking issues is also automatically handled by the Cast framework.
Mac Right (control) click the Git-it icon, select Open and then Open again. You can drag the icon into your Applications directory if you want, but it's not required. If needed, more detailed installation instructions can be found in this issue. Windows Double-click the executable. Linux Double-click the executable. If the app isn't running, see this issue. GitHub Desktop Focus on what matters instead of fighting with Git. Whether you're new to Git or a seasoned user, GitHub Desktop simplifies your development workflow. Download for macOS Download for Windows (64bit) Download for macOS or Windows (msi) Download for Windows. By downloading, you agree to the Open Source Applications Terms. Take control of startup and login items Is your Mac starting up slowly? A mess of startup and login items might be to blame. Learn how to bend these computing curiosities to your will. Startuip apps mac github.
Cast sessions are managed by the
GCKSessionManager
, which can be accessed via GCKCastContext.sharedInstance().sessionManager
. The GCKSessionManagerListener
callbacks can be used to monitor session events, such as creation, suspension, resumption, and termination.First we need to register our session listener and initialize some variables:
In
MediaViewController
, we are interested to be informed when we get connected or disconnected from the Cast device so we can switch to or from the local player. Note that connectivity can be disrupted not only by the instance of your application running on your mobile device, but it can also be disrupted by another instance of your (or another) application running on a different mobile device.The currently active session is accessible as
GCKCastContext.sharedInstance().sessionManager.currentCastSession
. Sessions are created and torn down automatically in response to user gestures from the Cast dialogs.Loading media
In the Cast SDK, the
GCKRemoteMediaClient
provides a set of convenient APIs for managing the remote media playback on the receiver. For a GCKCastSession
that supports media playback, an instance of GCKRemoteMediaClient
will be created automatically by the SDK. It can be accessed as the remoteMediaClient
property of the GCKCastSession
instance.Add the following code to
MediaViewController.swift
to load the currently selected video on the receiver:Now update various existing methods to use the Cast Session logic to support remote playback:
Now, run the app on your mobile device. Connect to your Cast device and start playing a video. You should see the video playing on the receiver.
The playback logic does not handle all of the use cases for switching back and forth between local and remote playback. As an exercise of a more complete solution take a look at the
MediaViewController
implementation from the app-done project.The Cast Design Checklist requires that all Cast apps provide mini controller to appear when the user navigates away from the current content page. The mini controller provide instant access and a visible reminder for the current Cast session.
The Cast SDK provides a control bar,
GCKUIMiniMediaControlsViewController
, which can be added to the scenes in which you want to show the persistent controls.For the sample app, we are going to use the
GCKUICastContainerViewController
which wraps another view controller and adds a GCKUIMiniMediaControlsViewController
at the bottom.Modify the
AppDelegate.swift
file:Google Cast Enabled App
Add this property and setter/getter to control the visibility of the mini controller (we will use these in a later section):
Run the app and cast a video. When playback starts on the receiver you should see the mini controller appear at the bottom of each scene. You can control the remote playback using the mini controller. If you navigate between the browse activity and the local player activity, the mini controller state should stay in sync with the receiver media playback status.
The Google Cast design checklist requires a sender app to introduce the Cast button to existing users to let them know that the sender app now supports Casting and also helps users new to Google Cast.
The
GCKCastContext
class has a method, presentCastInstructionsViewControllerOnce
, that can be used to highlight the Cast button when it is first shown to users. Add the following code to MediaViewController.swift
and MediaTableViewController.swift
:Chromecast Enabled App Tv
![Mac Mac](/uploads/1/3/3/8/133879158/688189049.jpg)
Run the app on your mobile device and you should see the introductory overlay.
Note: You might need to uninstall the app from the device before running it again to be able to see the overlay.
The Google Cast design checklist requires a sender app to provide expanded controller for the media being cast. The expanded controller is a full screen version of the mini controller.
The expanded controller is a full screen view which offers full control of the remote media playback. This view should allow a casting app to manage every manageable aspect of a cast session, with the exception of receiver volume control and session lifecycle (connect/stop casting). It also provides all the status information about the media session (artwork, title, subtitle, and so forth).
The functionality of this view is implemented by the
GCKUIExpandedMediaControlsViewController
class. Sharpdesk 3.3 download mac.The first thing you have to do is enable the default expanded controller in the cast context. Modify
AppDelegate.swift
to enable the default expanded controller:https://renewmono864.weebly.com/blog/youtube-mp3-free-download-mac. Add the following code to
MediaViewController.swift
to load the expanded controller when the user starts to cast a video:The expanded controller will also be launched automatically when the user taps the mini controller.
Run the app and cast a video. You should see the expanded controller. Navigate back to the list of videos and when you click on the mini controller, the expanded controller will be loaded again.
Initialization
Start with the App-Done folder. Add the following to the
applicationDidFinishLaunchingWithOptions
method in your AppDelegate.swift
file.Once you are done applying one or more customizations as mentioned in the rest of this codelab, commit the styles by calling the code below
Customizing Cast views
You can customize all views that the Cast Application Framework manages by having default styling guidelines across views. As an example, let's change the icon tint color.
You can override defaults on a per-screen basis if required. For example, to override the lightGrayColor for the icon tint color just for the expanded media controller.
Changing colors
You can customize the background color for all views (or individually for each view). The following code sets the background color to blue for all your Cast Application Framework provided views.
Changing fonts
You can customize fonts for different labels seen within cast views. Let's set all fonts to ‘Courier-Oblique' for illustration purposes.
Changing default button images
Add your own custom images to the project, and assign the images to your buttons to style them.
Changing the Cast button theme
You can also theme Cast Widgets using the UIAppearance Protocol. The following code themes the GCKUICastButton on all the views it appears:
You now know how to Cast-enable a video app using the Cast SDK widgets on iOS.
Take a look at our sample apps on GitHub: github.com/googlecast.