[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
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

Fri Oct 26 2018

How to setup Bitmovin iOS SDK with DRMToday content

OverviewLink Icon

Nearly every DRM license provider does have customized DRM workflow in place, which is different to the default approach, especially when it comes to Fairplay DRM. In order to support those custom requirements, each Bitmovin native SDK does support the same customizable callbacks as the HTML5 player, so you can adjust the DRM requests to the needs of your DRM provider accordingly.

If you are not yet familiar with the Bitmovin SDK, please see the related blog post and have a look at the demo applications available in our iOS sample applications or Android sample applications repository.

iOS SDK using DRMToday/Castlabs (Swift, Fairplay DRM)Link Icon

This example is based on the "BasicDRMPlayback" which is available in its sample application repository.

1let fpsConfig = FairplayConfiguration(license: licenseUrl, certificateURL: certificateUrl)
2
3let userData = "{\"userId\":\"YOURUSERID\", \"sessionId\":\"YOURSESSIONID\", \"merchant\":\"YOURMERCHANTSTRING\"}"
4let data = (userData).data(using: String.Encoding.utf8)
5let base64 = data!.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))
6
7fpsConfig.licenseRequestHeaders = ["dt-custom-data": base64]
8
9fpsConfig.prepareContentId = { (contentId: String) -> String in
10 let pattern="skd://drmtoday?"
11 //let contentId = contentId.substring(from: pattern.endIndex)
12 let contentId = String(contentId[pattern.endIndex...])
13 print("contentId: \(contentId)")
14 return contentId
15}
16
17fpsConfig.prepareMessage = { (data: Data, contentId: String) -> Data in
18 let base64String = data.base64EncodedString()
19 let uriEncodedMessage = base64String.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!
20 let message = "spc=\(uriEncodedMessage)&\(contentId)"
21 print("message: \(message.data(using: String.Encoding.utf8)!)")
22 return message.data(using: String.Encoding.utf8)!
23}

Give us feedback