Skip to main content
This guide walks through configuring an HTML5 video player with Bunny Stream’s FairPlay license server so encrypted videos can be played back securely on Safari and Apple devices.

What you’ll need

Before you dive in, make sure you have the following prerequisites in place:

Playing DRM content

Once video content is DRM encrypted, every play session needs a valid play license. Play license can be obtained from a License Server URL.
Note: Certificate and license server apply the same security mechanisms as player embed view. If referrer protection and/or token authentication is enabled in library settings, valid referrer header and/or token query parameters should also be provided to Fairplay DRM endpoints.

Certificate URL

To use Fairplay, player needs to obtain the Fairplay certificate first. It is accessible with the URL of the following pattern:

License server URL

Fairplay key server is accessible with the URL of the following pattern:
  • library_id: A unique identifier for the library or content collection.
  • video_id: The specific identifier for the FairPlay encrypted video.

Fairplay integration with Safari

Safari browsers on macOS and iOS inherently support the playback of HLS streams encrypted with Fairplay. To facilitate Fairplay integration on Safari, use the provided sample code:
Write a function to call the certificate-loading function and initiate video playback:
Define the onFpEncrypted function to handle the ‘encrypted’ event. It fetches the license, passes it to secure session, and enables Safari to decode the encrypted content:
Implement the getResponse function to send the SPC message to the FairPlay server and obtain the CKC for the encrypted session.
Place the following script block in the ‘head’ section or in a separate JavaScript file. This code ensures that video playback starts when the page is loaded.
Place the HTML5 video element on desired place in the html document.

Authentication

The license service endpoint employs referrer protection and embed token authentication to secure requests, similar to our player Embed View. That means if token authentication is enabled it should also be present in requests going to DRM license endpoint ( the same is for referrer protection and token authentication). These security rules ensure that only requests from authorized sources with valid tokens are processed if configured. For the authentication to work, it has to be enabled in dashboard: For more detailed guidance on these security mechanisms, please visit our Embed View Token Authentication page.