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

早过忘川 提交于 2019-12-08 11:40:36

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/38688762/how-to-play-audio-using-json-data-from-api-call-spreaker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!