# Apple FairPlay

Note

This feature is available only to ByteArk Video Cloud for Business customers. Please contact sales@byteark.com if you would like to use it.

ByteArk Player supports content protected with Apple FairPlay Streaming (FPS) (opens new window) on Safari (macOS, iOS, and iPadOS).

# DRM Source Object for FairPlay

Name Type Required Description
certificateUrl String Yes URL of the FairPlay certificate
processSpcUrl String Yes URL of the FairPlay license server
extractContentId Function No Callback receiving the initData URI from the needkey event, used to send a custom Content ID to the license server
extractKey Function No Callback receiving a response object (opens new window) used to convert response data into the playback key
licenseRequestHeaders Array<{name: String; value: String}> No Custom headers sent with the license request

# Example

{
  src: 'https://byteark-playertzxedwv.stream-playlist.byteark.com/streams/TZyZheqEJUwC/playlist.m3u8',
  type: 'application/x-mpegURL',
  drm: {
    fairplay: {
      certificateUrl: '<URL_TO_CERTIFICATE>',
      processSpcUrl: '<URL_TO_FAIRPLAY_LICENSE_SERVER>'
    }
  }
}
1
2
3
4
5
6
7
8
9
10

# Sending an Authorization Header

{
  src: 'https://byteark-playertzxedwv.stream-playlist.byteark.com/streams/TZyZheqEJUwC/playlist.m3u8',
  type: 'application/x-mpegURL',
  drm: {
    fairplay: {
      certificateUrl: '<URL_TO_CERTIFICATE>',
      processSpcUrl: '<URL_TO_FAIRPLAY_LICENSE_SERVER>',
      licenseRequestHeaders: [
        {
          name: 'Authorization',
          value: '<YOUR_AUTHORIZATION_HEADER>'
        }
      ]
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# Using extractContentId

{
  src: 'https://byteark-playertzxedwv.stream-playlist.byteark.com/streams/TZyZheqEJUwC/playlist.m3u8',
  type: 'application/x-mpegURL',
  drm: {
    fairplay: {
      certificateUrl: '<URL_TO_CERTIFICATE>',
      processSpcUrl: '<URL_TO_FAIRPLAY_LICENSE_SERVER>',
      extractContentId: function(initDataUri) {
        var uriParts = initDataUri.split('://', 1);
        var protocol = uriParts[0].slice(-3);
        uriParts = initDataUri.split(';', 2);
        var contentId = uriParts.length > 1 ? uriParts[1] : '';
        return protocol.toLowerCase() == 'skd' ? contentId : '';
      }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# Full source code example

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <div id="video-player"></div>
    <script src="https://byteark-sdk.cdn.byteark.com/player/v2/byteark-player.min.js"></script>
    <script>
      var player = bytearkPlayer('video-player', {
        fluid: true,
        poster: '/assets/samples/player/images/poster-big-buck-bunny.jpg',
        sources: [
          {
            title: 'FairPlay Source',
            src: 'https://byteark-playertzxedwv.stream-playlist.byteark.com/streams/TZyZheqEJUwC/playlist.m3u8',
            type: 'application/x-mpegURL',
            drm: {
              fairplay: {
                certificateUrl: '<URL_TO_CERTIFICATE>',
                processSpcUrl: '<URL_TO_FAIRPLAY_LICENSE_SERVER>',
                licenseRequestHeaders: [
                  {
                    name: 'Authorization',
                    value: '<YOUR_AUTHORIZATION_HEADER>'
                  }
                ]
              }
            }
          }
        ],
        plugins: {
          bytearkShaka: {}
        }
      });
      window.player = player;
    </script>
  </body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40