JSON/MRSS Feed from a Playlist

In this sample, you will learn how to retrieve a playlist using the Playback API and generate a JSON or MRSS video feed from the data. This can also be done with the CMS API, but using the Playback API allows you to create a pure client-side app, without having to route the API request through a server-side proxy.

Introduction

This is a simple example of how to use the Playlist API to get the data for a Video Cloud playlist and present it either as JSON or MRSS data that you could pass to a syndication partner.

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.

Requirements

To build this yourself, you need two things:

  • A Video Cloud playlist id, which you can obtain from Studio
  • A policy key for your Video Cloud account, which you can obtain from any Brightcove Player in your account, or from the Policy API

Optional

You don't need to do this for any functional reason, but to prettify the MRSS code and make it easier to read, we have included the vkBeautify JavaScript library.

The rest is a little bit of HTML and JavaScript, explained in detail in the How it's done section below.

The feed generator

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

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