List tracks from Soundcloud and play it with Soundmanager 2 on a Wordpress blog

為{幸葍}努か 提交于 2019-12-02 02:59:23

You need to get the stream URI using Soundcloud's API. You can get the stream URI by making a request like:

https://api.soundcloud.com/tracks/5677638.json

where 5677638 is the id of the track you want to get the info of.

But you do need an API key which you can request for free at: Soundcloud Developers

So after that you can make a request like:

https://api.soundcloud.com/tracks/5677638.json?consumer_key={your api key}

That request will get you an json encoded string which contains all the info about the track, e.g.:

{
  "id": 5677638,
  "created_at": "2010/09/29 19:46:01 +0000",
  "user_id": 378405,
  "duration": 183945,
  "commentable": true,
  "state": "finished",
  "sharing": "public",
  "tag_list": "electro electrohouse remix green velvet remixcontest remixcompetition remixcomp foem uptempo",
  "permalink": "green-velvet-feat-santiago-bushido-turn-it-up-sander-van-halem-remix",
  "description": "Now let's turn it up up up up! :D Remix comp at http://foem.info/index.php?option=com_content&task=view&id=383&Itemid=97 . Some feedback would be appreciated. ",
  "streamable": true,
  "downloadable": true,
  "genre": "",
  "release": "",
  "purchase_url": null,
  "label_id": null,
  "label_name": "",
  "isrc": "",
  "video_url": null,
  "track_type": "remix",
  "key_signature": "",
  "bpm": 128,
  "title": "Green Velvet feat. Santiago and Bushido - Turn It Up (Sander van Halem Remix)",
  "release_year": null,
  "release_month": null,
  "release_day": null,
  "original_format": "mp3",
  "license": "all-rights-reserved",
  "uri": "https://api.soundcloud.com/tracks/5677638",
  "permalink_url": "http://soundcloud.com/sander-van-halem/green-velvet-feat-santiago-bushido-turn-it-up-sander-van-halem-remix",
  "artwork_url": "http://i1.sndcdn.com/artworks-000002478404-sy6zd5-large.jpg?6cbf23e",
  "waveform_url": "http://w1.sndcdn.com/1Iydbj7KnvOi_m.png",
  "user":  {
    "id": 378405,
    "permalink": "sander-van-halem",
    "username": "Sander van Halem",
    "uri": "https://api.soundcloud.com/users/378405",
    "permalink_url": "http://soundcloud.com/sander-van-halem",
    "avatar_url": "http://i1.sndcdn.com/avatars-000000760311-hwm8iz-large.jpg?6cbf23e"
  },
  "stream_url": "https://api.soundcloud.com/tracks/5677638/stream",
  "download_url": "https://api.soundcloud.com/tracks/5677638/download",
  "playback_count": 1386,
  "download_count": 67,
  "favoritings_count": 17,
  "comment_count": 34,
  "attachments_uri": "https://api.soundcloud.com/tracks/5677638/attachments"
}

As you can see there is an stream_url item which contains the URL you can use to 'embed' the track using SoundManager just like you would with a local mp3.

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