Вопрос

I would like to be able to constantly get the 10 last tracks of a user using oembed with json.

$.getJSON("http://soundcloud.com/oembed", 
          {url: "https://soundcloud.com/aviciiofficial", format: "json"},
function(data)
{
    console.log(data.html);
})

Data.html returns the soundcloud player's html code, but this player contains a track set with all the users tracks. I would like to be able to get the tracks individually (something like this: data[0].html). How can i fetch an array of all the newest tracks?

Console output:

<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fusers%2F1861068"></iframe>

Thanks!

Это было полезно?

Решение

What you will have to do is to issue an API request to retrieve user’s tracks, there is no oembed endpoint that would return list of embeds.

UPD.

So, in order to show the artwork widgets you need to iterate over the array, and replace the API_URL and COLOR with each items API url and the color you want (perhaps you can set the color once for all of them actually).

'<object height="300" width="300">' + 
  '<param name="movie" value="https://player.soundcloud.com/player.swf?url={{API_URL}}&amp;color={{COLOR}}&amp;auto_play=false&amp;player_type=artwork">' +      
  '</param>' +
  '<param name="allowscriptaccess" value="always"></param>' +
  '<embed allowscriptaccess="always" width="300" height="300" ' + 
    'src="https://player.soundcloud.com/player.swf?url={{API_URL}}&amp;color={{COLOR}}&amp;auto_play=false&amp;player_type=artwork" ' +
    'type="application/x-shockwave-flash">' + 
  '</embed>' + 
'</object>';

I have described this previously in the following answer – Retrieve Soundcloud search results and embed results, only in context of HTML5 widget.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top