Playback API Sample: MRSS Generator

Product(s)
Video Cloud
Role(s)
API Developer
API(s)
Playback API
Policy API
Type
Support Doc

In this sample, you will learn how to use the Playback API to generate an MRSS feed based on the MRSS specification.

Limitations

For the security of your content, the URLs for videos and assets returned by Brightcove APIs are signed, meaning that they include a token that is only good for a short time - usually a few hours, but this can vary depending on the account configuration. This means that the URLs in the MRSS code generated by this tool will only be good for the period of time.

You can deal with this in one of two ways:

  • You can ask Brightcove Support to increase the "time-to-live" for the tokens attached to media URLs for your account. The value can be set to any period up to one year. However, be aware that this is an account-level setting and the change will apply to all your videos.
  • Alternatively, you can create your own version of this app, and have it create a fresh version of your MRSS feed on a regular basis, within the token life.

Alternative samples

We have some additional samples of generating MRSS feeds using the CMS API via a proxy app:

You may also be interested in this alternative sample created in PHP alone by a Brightcove customer.

The only advantage of using the Playback API over the CMS API is that the app is entirely client side - no server-side proxy is required to get access tokens.

Authentication

Requests are authenticated by a policy key, which can be passed in one of three ways:

  1. In an argument to an Accept header:
    Accept: application/json;pk={policy_key}

    This is the recommended method for a browser-based client, because it allows the request to go ahead without an extra request first as part of the browser CORS "pre-flight" checking. This saves latency on the first time a browser request is made.

  2. In an Authorization header using the realm keyword BCOV-Policy:
    Authorization: BCOV-Policy {policy_key}
  3. In a BCOV-Policy header:
    BCOV-Policy: {policy_key}

Obtaining a policy key

This app requires a search-enabled policy key. The default policy keys added to Brightcove Players automatically are not search-enabled, so you cannot use one of these keys. There are two ways you can generate a search-enabled a policy key:

  1. You can generate a basic policy key using the Policy Keys Quick Start
  2. You can make a request to the Policy API

Dependencies

  • vkBeautify (to pretty-print the XML for the MRSS feed)

Working sample

Find all the code associated with this sample in this GitHub repository.

See the Pen Playback API: MRSS Generator by Brightcove Learning Services (@rcrooks1969) on CodePen.

Using the CodePen

Here are some tips to effectively use the above CodePen:

  • Toggle the actual display of the player by clicking the Result button.
  • Click the HTML/CSS/JS buttons to display ONE of the code types.
  • Click Edit on CodePen in the upper right corner to fork this CodePen into your own account.
  • Find all the code associated with this sample in this GitHub repository.