Playing On-Demand content
There are several ways to play on-demand content with the Radioplayer Web Player. We will address two methods here: direct embed, and odId.
Direct embed
Using direct embed allows you to pass the details of the content directly to the player via the configuration properties. This is the fastest and most robust method, as there is no lookup required. This is done by passing an OnDemandItem to the player, containing the details of the content. This can be genetrated by your CMS. For example, the following tag will play a podcast:
<div data-widget-radioplayer>
<script type="application/json">
{
"id": "350",
"onDemandItem": {
"streams": [{
"url": "https://open.live.bbc.co.uk/mediaselector/6/redir/version/2.0/mediaset/audio-nondrm-download/proto/https/vpid/p051cyzc.mp3",
"format": "mp3"
}],
"seriesName": "50 Things That Made the Modern Economy",
"episodeName": "Cuneiform",
"description": "Cuneiform, the earliest known script, wasn’t used for poetry, or to send messages to far-off lands. It was used to create the world’s first accounts and written contracts.",
"imageUrl": "https://ichef.bbci.co.uk/images/ic/640x360/p0516j48.jpg",
"startTimeString": "Mon, 01 May 2017 03:50:00 GMT"
},
"mapi": "https://mapi.radioplayer.co.uk/api/uk/",
"cm": "https://cookie.radioplayer.co.uk/cm/",
"np": "https://np.radioplayer.co.uk/qp/",
"qp": "https://search.radioplayer.co.uk/qp/",
"stationLogo": "https://static.bbc.co.uk/radio/player/3.29.20180525095128/img/logo/nations/bbc_world_service.png",
"theme": "DARK"
}
</script>
</div>
You should not pass a fallback
stream list when playing on demand content, as
it is ignored. All other options can be passed, however, allowing you to
configure the player in the same way as the live player.
odId
An alternative way to play on demand content is to use an odId
in the URL
query string. This allows you to use the same player as for live streams. If the
odId param is present, then the player will fetch the details of that item from
the Radioplayer API, and play that content instead of the live stream. You
should ensure that all of the normal options are passed to the player in the
options object.
For example, if your player URL is http://example.com/player
, then you could
play an on demand item by loading http://example.com/player?odId=123456789
.
The odId is generated during ingest, and the corresponding on-demand player URLs
with odIds can be generated at the same point.