嘿,我希望能够使用我的jplayer播放公共声音云流。 我想使用soundclouds自己的api方法,所以我注册了一个应用程序并尝试使用
http://api.soundcloud.com/tracks/trackid/stream?client_id=client_id
当我访问链接时,这在浏览器中有效,但在我当前的代码中,我需要一个带有结尾.mp3的链接来播放音频。由于soundloud使用302重定向到mp3网址,它无法正常工作。
获取音频网址的当前代码
$(document).ready( function() {
if (getCookie("volume")=="") {
player_volume=0.8;
setCookie("volume",0.8,"365")
}
else {
player_volume=getCookie("volume")
}
$("#sound-player").jPlayer({ready:function(a) {
$(this).jPlayer("setMedia",{})},cssSelectorAncestor:"#sound-container",swfPath:"themes/sound/js",supplied:"mp3",wmode:"window",volume:player_volume,smoothPlayBar:true,keyEnabled:true})
});
function playSong(c,e) {
if (/Opera Mini/i.test(navigator.userAgent)) {
window.location=""+c;
return false
}
$(".current-song").removeClass("current-song");
$(".current-play").show();$(".current-play").removeClass("current-play");
$(".current-seek").html($("#sound_ghost_player").html());
$(".current-seek").removeClass("current-seek");
var b=c.replace(".","\\.");
$("#track"+e).addClass("current-song");
$("#play"+e).addClass("current-play");
$(".current-play").hide();
if ($("#song-name"+e).html().length>25) {
var d=$("#song-name"+e).html().substr(0,25)+"..."
}
else {
var d=$("#song-name"+e).html()
}
$("#sw-song-name").html(d);
$(".jp-audio .jp-time-holder").show();
$("#sound-player").jPlayer("destroy");
$("#song-controls"+e).html($("#seek-bar-song").html());
$("#song-controls"+e).addClass("current-seek");
$("#track"+e+" .jp-play , #track"+e+" .jp-pause").css({"margin-top":"-"+$(".song-top","#track"+e).outerHeight()+"px"});
var a=getExtension(c);
prevnext();
$("#sound-player").jPlayer({ready:function(f) {
if (a=="mp3") {
$(this).jPlayer("setMedia", {mp3:"https://api.soundcloud.com/tracks/"+c}).jPlayer("play")
}
else {
if (a=="m4a") {
$(this).jPlayer("setMedia", {m4a:"https://api.soundcloud.com/tracks/"+c}).jPlayer("play")
}
}
}, cssSelectorAncestor:"#sound-container",ended: function() {
$.ajax({
type:"POST",
url:"",
data:"id="+e,
cache:false,
success:function(f){}
});
if ($("#repeat-song").html()==0) {
$(".current-seek").html($("#sound_ghost_player").html());
$(".current-play").show();
nextSong(e)
}
},
errorAlerts:true,
swfPath:"themes/sound/js/",
supplied:a,
wmode:"window",
volume:getCookie("volume"),
smoothPlayBar:true,
solution:"html, flash",
keyEnabled:true
})
}
我希望有人可以帮助我