Chromecast from iOS using GoogleCast SDK (part 2)

sz-ashik
1 min readOct 6, 2022

--

In the last article, we completed our basic configuration for GoogleCast. It’s time to start casting 🥳

Last time, we added GCKUICastButton to the navigation bar. This will present GCKUIInformationAlertViewController with a list of available Chromecast-supported devices/TVs. Select the tv where you want to Cast your video.

GCKUIInformationAlertViewController View

By selecting a device/TV, a GCKSessionManager will start with a GCKDevice instance. To observe the session state, set GCKSessionManagerListener to ViewController

Now that we have started a session, we can Cast video/image to Chromecast. Let's prepare an GCKMediaInfromtaion using the media’s metadata to send to the receiver app(Chromecast). Then get the current session from the session manager. The session manager has an GCKRemoteMediaClient instance for controlling media, e.g. load media, play, pause, etc.

Just call the castVideo method from a button action and the video will be Cast to your device/TV.

Cheers, now we can Cast video/image into Chromecast supported devices with ease. Just replace media metadata with your own metadata, you can Cast that

--

--