列出Soundcloud中的曲目,并在Wordpress博客上与Soundmanager 2一起播放 [英] List tracks from Soundcloud and play it with Soundmanager 2 on a Wordpress blog

查看:397
本文介绍了列出Soundcloud中的曲目,并在Wordpress博客上与Soundmanager 2一起播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这并不是寻求完美编码解决方案的呼声,但如果有人至少可以给我一些有关如何解决此问题的提示,那将是完美的:我拥有一个自定义的Wordpress网站作为记录标签.当然,在此站点上,有一个部分显示了其艺术家的每首曲目的发行版本.

first of all this is not a cry for a perfectly coded solution but it would be perfect if someone could at least give me some tips on how to solve this problem which is: I have this custom Wordpress site for a record label. On this site there is of course a section showing the releases of every of their artist's tracks.

客户端需要将其所有曲目上载到Soundcloud.在WP后端中,他们可以使用MagicFields for Wordpress输入专辑名称,上传封面图像并添加所需的曲目.添加专辑信息和曲目名称后,他们可以输入Soundcloud上托管的特定曲目的URL.然后,WP将所有这些轨道列出如下:

The client needs to upload all their tracks to Soundcloud. In the WP backend they can enter the name of the album, upload a cover image and add as many tracks as they want using MagicFields for Wordpress. After adding the album information and the track names they can enter the URL of the specific track hosted on Soundcloud. WP then lists all of these tracks as following:

(似乎我无法上传图片,因此这里是链接) http://postimage.org/image/22ob8ymys/

(It seems I can not upload images so here is the link) http://postimage.org/image/22ob8ymys/

在左侧,您可以看到Soundmanager2的360度可视化.现在,MP3已上传到标签的网站(我需要更改),每个列表项的链接如下所示:

On the left side you can see Soundmanager2's 360 visualization. Right now the MP3s are uploaded to the label's website (which I need to change) and the link of each list item looks something like this:

<ol>
  <a href="#" onclick="if (threeSixtyPlayer.lastSound) { threeSixtyPlayer.lastSound.stop(); } document.getElementById('mp3').href = 'track1.mp3'; threeSixtyPlayer.handleClick({target: document.getElementById('mp3')});"><li>Track 1</li></a>
  ...
</ol>

如您所见,该链接指向特定文件,以扩展名.mp3结尾,以使其可通过SM2播放.但是,您可能知道您无法轻松地在Soundcloud上访问MP3.传递"www.soundcloud.com/artist/track1"之类的网址似乎无效.

As you can see the link leads to specific files, ending with the extension .mp3 to make it playable via SM2. But as you might know you can not easily access an MP3 on Soundcloud. Passing an URL like 'www.soundcloud.com/artist/track1' seems not to work.

我已经对Soundcloud的API进行了一些研究,但是猜猜是什么,对我来说太难了(这就是为什么我在这里). http://soundcloud-sm2.heroku.com/docs/application.html 非常接近我要寻找的内容,但不幸的是我无法使用它,因为曲目不应该通过JS而是通过PHP包含在站点中.

I've made some research about Soundcloud's API but guess what, it's too complex for me to understand (that's why I am here). The documentation on http://soundcloud-sm2.heroku.com/docs/application.html came quite close to what I was looking for but unfortunately I can not use it because the tracks should not be included on the site via JS but PHP.

我希望你们中的某人可以给我一些有关如何解决此特定问题的提示. 感谢您阅读到目前为止;)

I hope someone of you could give me some tips on how to solve this specific problem. Thanks for reading this far ;)

推荐答案

您需要使用Soundcloud的API获取流URI.您可以通过发出如下请求来获取流URI:

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

其中5677638是要获取其信息的曲目的ID.

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

但是您确实需要一个可以免费索取的API密钥: Soundcloud开发人员

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}

该请求将为您提供一个json编码的字符串,其中包含有关曲目的所有信息,例如:

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"
}

如您所见,有一个stream_url项,其中包含可用于使用SoundManager嵌入轨道的URL,就像使用本地mp3一样.

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.

这篇关于列出Soundcloud中的曲目,并在Wordpress博客上与Soundmanager 2一起播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆