Enable casting to Chromecast devices

Learn how to enable casting with the iOS SDK.

The Google Cast framework enables a viewer to stream video and audio content to a compatible TV or sound system. By enabling the Google Cast framework in your app, a viewer can use a cast button to stream your content to a Chromecast-enabled device on a shared network connection.



• The JW Player iOS SDK supports casting to the Default Media Receiver and to Styled Media Receivers.

• Custom receivers are not officially supported. However, if the video playback implements the same interface used in the Default Media Receiver, you may be able to initiate a casting session with a custom receiver.

• To specify a receiver and start scanning for devices, pass a media receiver app ID to the withAppId argument of the startScanningForDevices method of the JWCastController.


Google Cast SDKThis SDK handles discovery of, casting to, and disconnecting from chromecast devices.

1. Download the framework.
2. Manually add the framework to your project.
  • This step includes manually adjusting project settings, and adding 15+ standard frameworks to the project, as described in the link.

3. Initialize the Google Cast SDK in your AppDelegate.



The JWP iOS SDK's cast integration requires that you link your app to the dynamic build of the Google Cast SDK. Since Google only distributes its static libraries via CocoaPods, there is no CocoaPods integration option — only the manual download approach described above is possible.

Set up permissions

  1. If you are using Xcode 12 and targeting iOS 12+, enable Access Wifi Information.

    • Click the app target > Capabilities > Access WiFi Information.
    • Click the toggle to ON to enable Access Wifi Information.

  2. (Guest mode only) In the Info.plist for your app, add NSBluetoothAlwaysUsageDescription to create a Bluetooth access request. If you are using the google-cast-sdk-no-bluetooth dependency, you can skip this step.
  3. (iOS 14) In the info.plist, add the following two keys:
    NSBonjourServices with _googlecast._tcp and _<your-app-id>._googlecast._tcp inside the array
<string>${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi

Configure and enable casting

  1. Initialize the CastContext as described in Google's article, Integrate Cast Into Your iOS App.

  2. In your app, create a JWCastController object and set its delegate. The delegate must adhere to the JWCastDelegate protocol and implement its delegate methods.
func setUpCastController() {
    castController = JWCastController(player: player)
    castController?.delegate = self
- (void)setUpCastController
    self.castController = [[JWCastController alloc] initWithPlayer:self.player];
    self.castController.delegate = self;
  1. Call startDiscovery() to scan for devices.

    Once available devices are discovered, the event is reported to the JWCastDelegate method, devicesAvailable:. This method supplies a list of available devices within range as an array of JWCastingDevice.
func beginScanning() {
- (void) beginScanning
    [self.castController startDiscovery];
func castController(_ controller: JWCastController, devicesAvailable devices: [JWCastingDevice]) 
    availableDevices = devices
-   (void)castController:(JWCastController *)controller devicesAvailable: (NSArray<JWCastingDevice *> *)devices
    self.availableDevices = devices;
  1. Call the connectToDevice: method to connect to a device.

    When a connection is established, the JWCastingDelegate method, connectedTo:, is called. This signals the ability to cast the video that is reproduced by the JWPlayer instance.
func onUserSelectedDevice(_ index: Int!) 
    let chosenDevice = availableDevices[index]
    JWCastingDevice *chosenDevice = availableDevices[index];
    [self.castController connectToDevice:chosenDevice];
  1. Call cast() on the JWCastController instance.
func castController(_ controller: JWCastController, connectedTo device: JWCastingDevice) {
-   (void)castController:(JWCastController *)controller connectedTo:(JWCastingDevice *)device
    [self.castController cast];

The JWPlayer API controls the playback of the video being casted. The JWPlayerDelegate provides the playback callbacks while casting.


Are there changes in iOS 13 that may impact my app?
Which features are not supported when casting with an iOS SDK player?

Did this page help you?