jquery - Play Soundcloud Audio Streams with Jplayer -
hey want able play public soundcloud stream jplayer. thought of using soundclouds own api method, registered app , tried use
http://api.soundcloud.com/tracks/trackid/stream?client_id=client_id
this works in browser when visit link in current code need link ending .mp3 play audio. since soundloud using 302 redirect mp3 url, isnt working.
current code grabbing audio url
$(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 }) }
i hope can me out
Comments
Post a Comment