Reputation: 11
I'm trying to play an audio file from this json data.
http://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 using Fetch.
How would I go about grabbing the JSON data, then outputting it as audio?
The original audio stream url is: https://www.spreaker.com/user/spr-radio/spr_151
Upvotes: 0
Views: 296
Reputation: 130
You would need the raw audio stream, if spreaker lets you form that url from the api, you would be set. It doesn't seem as if it does, but I haven't looked into its docs yet. Assuming you could get the raw audio url (it looks like spreaker is only offering the site's url) you could use javascript to run a get request on the api (as you have it seems), parse the json and add it as a source to an html audio element (if not make one in javascript and inject it into your page where needed).
Not sure if that's the approach you're looking for, or if you're asking for something else. Audio elements have a number of odd things about them.
Upvotes: 1