brightcove

How to pass policyKey to Brightcove react-player-loader?


I'm trying to use Brightcove react-player-loader, but there doesn't seem to be any documented way to pass the policyKey to the player. Brightcove has a web page where you can test assets using a Codepen. It requires accountId, videoId and policyKey. My test asset can be accessed on that web page, so I know it works, but how do I use the policyKey with react-player-loader? There is no mention of policyKey in the documentation.


Solution

  • You'd set it with player.catalog.setPolicyKey(MY_POLICY_KEY) on the initialised player, whcih you access in an onSuccess handler. This only works with an "in-page" and not an iframe type embed.

    function (success) {
      const player = success.ref;
      player.ready(function () {
        player.catalog.setPolicyKey('abcd...');
        player.catalog.get({type: 'video', id: '1234'}).then(player.catalog.load);
      });
    }