In this topic, you will learn how to configure Brightcove Player to use Brightcove's Playback Rights.
Introduction
By default, the Brightcove Player talks to the Brightcove Playback API. A new system to manage playback rights and restrictions sits in front of the Playback API and provides playback authorization using DRM licenses.
If you are not familiar with this feature, see the Overview: Managing Playback Rights document.
Request with playback rights
To utilize playback rights, follow these steps:
-
The Brightcove Player makes a request to the Playback API if it has a policy key. This is the default for all Brightcove Players. The first step is to remove the default policy key built into the player:
player.catalog.setPolicyKey(null);
-
If you have user-level restrictions, you need an authorization token. When specified, this token is added as an Authorization header for any subsequent requests.
You can add one to the player as follows:
player.catalog.setBcovAuthToken('your jwt token');
-
After changing the policy key and/or authorization token, you are ready to request data from the Brightcove Playback API and load it into the player. This process is identical to the default case.
Here is an example of fetching a single video with playback restrictions and an authorization token:
HTML
<div style="max-width: 960px;"> <video-js id="myPlayerID" data-embed="default" controls="" data-application-id="" class="vjs-fluid"></video-js> </div> <script src="https://players.brightcove.net/your account id/your player id_default/index.min.js"></script>
JavaScript
<script> // +++ Add the player attributes +++ var myPlayer, myPlayerEl = document.getElementById("myPlayerID"); myPlayerEl.setAttribute('data-account', your account id); myPlayerEl.setAttribute('data-player', 'your player id'); // +++ Create the player +++ myPlayer = bc(myPlayerEl); // Unset the player policy key myPlayer.catalog.setPolicyKey(null); // Set the authorization token myPlayer.catalog.setBcovAuthToken('your jwt token'); // This should trigger a request to: // // https://edge-auth.api.brightcove.com/playback/v1/videos/1 // // With header: // // Authorization: Bearer <span class="bcls-input">your jwt token</span> // myPlayer.catalog.get({id: 'your video id', type: 'video'}). then(function(data) { myPlayer.catalog.load(data); myPlayer.muted(true); myPlayer.play(); }). catch(function(error) { throw new Error(error); }); </script>
Request without playback rights
This process can be reversed to direct requests back to Playback API without rights and restrictions.
Set the policy key and authorization token as follows:
player.catalog.setPolicyKey('your policy key');
player.catalog.setBcovAuthToken(null);