我在我的网站上使用Soundmanager Mp3按钮。但是,我想使用Soundcloud Api通过Soundmanager流式传输音轨,而不是托管MP3。基本上,我想通过Soundmanager按钮传送Soundcloud链接。可能?通过Soundmanager2播放SoundCloud链接
我试过创建一个jQuery循环(下面),但仍然没有任何运气。
<ol>
<li><a class="sm2_button" href="http://soundcloud.com/....">Track Title</a>
</li>
</ol>
和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() {
// and place an 'onclick' on each link
$(thisLink).attr('onclick', "if (basicMP3Player.lastSound) { basicMP3Player.lastSound.stop(); } document.getElementById('mp3').type='audio/mpeg'; document.getElementById('mp3').href = '" + url + "'; basicMP3Player.handleClick({target: document.getElementById('mp3')});");
});
});
一些对SoundManager类论坛中的主题可以帮助你:https://getsatisfaction.com/schillmania一堆挖我能得到它,如果我在链接中指定的MIME类型MP3的工作后,/searching?query = soundcloud&x = 0&y = 0&style = topics – nickf
试过了。在这里疯狂哈哈。当链接到一个托管的mp3,但不soundcloud链接时完美播放 – Graphicd02