ahayes
ahayes

Reputation: 11

How to play audio using JSON data from API call? (Spreaker)

I'm trying to play an audio file from this json data.

https://api.spreaker.com/v2/episodes/5816235

  "episode":{  
     "episode_id":5816235,
     "type":"LIVE",
     "title":"SPR",
     "duration":null,
     "show_id":1341125,
     "author_id":7883468,
     "site_url":"https:\/\/www.spreaker.com\/episode\/5816235",
     }

Specifically, I'd like to scope into the episode_id, to play the live stream. As I am new to using API calls, what's the best way to use the data to play the audio? Is there a way to access it using Javascript?

Should I use something like Plyr? https://github.com/Selz/plyr

Upvotes: 0

Views: 2231

Answers (1)

Marco Pracucci
Marco Pracucci

Reputation: 81

I'm Marco, a Spreaker engineer. You can get the audio stream of any episode from the URL:

https://api.spreaker.com/listen/episode/EPISODE-ID/http

(please replace EPISODE-ID with the ID of the episode you wanna play)

You can then use that URL to play the episode in basically any player, including the <audio> tag on modern browsers.

Why Spreaker doesn't have an SDK?

We're currently in the process of finalizing and releasing a javascript SDK that will ease playing a Spreaker episode on web. Once ready, it will be published at https://developers.spreaker.com

Upvotes: 1

Related Questions