[object Object] Icon

Learn how to create, start, manage and modify Encodings

[object Object] Icon

Learn how to create, start, manage and modify Players

[object Object] Icon

Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Wed Jul 14 2021

How to switch sources when casting via Bitmovin iOS SDK

OverviewLink Icon

A common use case is to leverage our iOS native SDK in order to play HLS streams with Fairplay DRM protection on iOS devices. This solution works very well for protecting the content whilst ensuring compatibility with iOS native system.

However, this presents some issues if you'd like to enable casting from your iOS app to devices such as ChromeCast, which doesn't support Fairplay. In scenarios like this, it's possible to instruct your app to switch to a different streaming and DRM format that is ChromeCast compatible, such as DASH + Widevine DRM.

Switch from HLS Fairplay to DASH WidevineLink Icon

As shown in this github example, it's quite easy to switch to a different streaming and DRM format when casting to a 3rd party device. Here is the relevant piece of code that handles this:

1// Provide a different SourceConfig for casting. For local playback we use a HLS stream and for casting a
2// Widevine protected DASH stream with the same content.
3 config.remoteControlConfig.prepareSource = { type, sourceConfig in
4 switch type {
5 case .cast:
6 // Create a different source for casting
7 guard let streamUrl = URL(string: "https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/mpds/11331.mpd"),
8 let licenseUrl = URL(string: "https://widevine-proxy.appspot.com/proxy") else {
9 return nil
10 }
12 // Create DASHSource as a DASH stream is used for casting
13 let castSourceConfig = SourceConfig(url: streamUrl, type: .dash)
14 castSourceConfig.title = sourceConfig.title
15 castSourceConfig.sourceDescription = sourceConfig.sourceDescription
17 let widevineConfig = WidevineConfig(license: licenseUrl)
18 castSourceConfig.drmConfig = widevineConfig
20 return castSourceConfig
21 }
22 }

Give us feedback