我在我的网站上使用Soundmanager Mp3按钮.但是,我想使用Soundcloud Api通过Soundmanager流式传输音轨,而不是托管MP3.基本上,我想通过Soundmanager按钮流式传输Soundcloud链接.可能?
我已经尝试创建一个jQuery循环(下面),但仍然没有运气.
<ol>
<li><a class="sm2_button" href="http://soundcloud.com/....">Track Title</a>
</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
和jQuery
$("ol a").each(function()
{
var thisLink = $(this);
var track_url = this.href; // save href value of each link to 'track_url' i.e. soundcloud.com/...
this.href = this.href.replace(track_url, "#"); // replace href value with '#'
var consumer_key = 'My Consumer Key';
// now resolve the stream_url through Soundcloud's getJSON method
$.when($.getJSON('http://api.soundcloud.com/resolve?url=' + track_url + '&format=json&consumer_key=' + consumer_key + '&callback=?', function(track) {
url = track.stream_url + '?consumer_key=' + consumer_key;
})).done(function() {
// …Run Code Online (Sandbox Code Playgroud)