Chromecast (iOS SDK)

The Dailymotion Cast SDK allows you to easily integrate a casting feature on your Dailymotion Player with minimum requirements.

👍

Chromecast module is optional

The iOS SDK can be integrated without the Chromecast module. It is optional and can be excluded based on your project requirements.

💡

Demo

Check our sample apps for an example on how to use, integrate and customise the Cast SDK with the Dailymotion Player on iOS environment



Prerequisites




1. Add NSBonjourServices to your Info.plist

Specify NSBonjourServices in your Info.plist file to allow local network discovery to succeed on iOS 14.

Add both _googlecast._tcp  and _B88B034A._googlecast._tcp  as services to allow proper device discovery as follow:

<key>NSBonjourServices</key>
<array>
  <string>_googlecast._tcp</string>
  <string>_B88B034A._googlecast._tcp</string>
</array>

2. Add NSLocalNetworkUsageDescription to your Info.plist

We strongly recommend customizing the message shown in the "Local Network" prompt to explain why your app needs access to the users' local network.

Add in your Info.plist file an app-specific permission string for NSLocalNetworkUsageDescription explaining that your app needs access to the users' local network to discover cast-enabled devices and other discovery services, like DIAL. Customize the message as you need.

<key>NSLocalNetworkUsageDescription</key>
<string>${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi
network.</string>

This prompt appears as part of the iOS Local Network Access dialog the first time users try to cast from your app.



3. Add a cast button

In order for the cast feature to be operational, you need to add a cast button in the UI. You can use the default one provided by the Google Cast SDK .

let castButton = GCKUICastButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24))
castButton.tintColor = UIColor.gray
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: castButton)

Find more info about the cast button in Google Cast documentation .


4. Mini controller and expanded controller (Optional)

Enrich the user experience using the UI controller options provided by default in the Google Cast SDK:

5. UI customization (Optional)

You can customize the Google Cast SDK provided UI as shown below:

// Get the shared instance of GCKUIStyle
let castStyle = GCKUIStyle.sharedInstance()
 
// Set the property of the desired cast Views
// Navigation bar buttons style
castStyle.castViews.deviceControl.connectionController.navigation.buttonTextColor = .black
 
// Tool bar style
castStyle.castViews.deviceControl.connectionController.toolbar.backgroundColor = .white
castStyle.castViews.deviceControl.connectionController.toolbar.buttonTextColor = .black
 
// Connection controller style
castStyle.castViews.deviceControl.connectionController.backgroundColor = .white
castStyle.castViews.deviceControl.connectionController.iconTintColor = .black
castStyle.castViews.deviceControl.connectionController.headingTextColor = .black
castStyle.castViews.deviceControl.connectionController.bodyTextColor = .black
 
// Device chooser style
castStyle.castViews.deviceControl.deviceChooser.backgroundColor = .white
castStyle.castViews.deviceControl.deviceChooser.iconTintColor = .black
castStyle.castViews.deviceControl.deviceChooser.headingTextColor = .black
castStyle.castViews.deviceControl.deviceChooser.captionTextColor = .black
 
// Refresh all currently visible views with the assigned styles
castStyle.apply()

Find more information and examples on how to style the default UI in Google Cast documentation .