I am trying to make it so that my audio player can pull MP3's off of other links and stream them through jPlayer.
var solution="html,flash";var mac=navigator.userAgent.indexOf("Mac OS X");var w51=navigator.userAgent.indexOf("Windows NT 5.1");var ie8=navigator.userAgent.indexOf("MSIE 8.0");var firefox=navigator.userAgent.indexOf("Firefox");var chrome=navigator.userAgent.indexOf("Chrome");if(mac!=-1&&firefox!=-1||w51!=-1&&firefox!=-1||ie8!=-1)
{solution="flash,html";}var resource={};if(chrome!=-1&&"mp3"=="mp3"){resource["m4a"]="somemusicfile.mp3";}else{resource["mp3"]="somemusicfile.mp3";}
$("#podbean_palyer").jPlayer({ready:function(event){$(this).jPlayer("setMedia",resource);},play:function(){removeMask();},loadedmetadata:function(){removeMask();},error:function(event){switch(event.jPlayer.error.type){case $.jPlayer.error.URL:removeMask();break;case $.jPlayer.error.NO_SOLUTION:removeMask();break;}},swfPath:"",supplied:"m4a,oga,mp3",solution:solution,cssSelectorAncestor:"#pd_container",wmode:"window",smoothPlayBar:true,keyEnabled:true,});
My code is beyond messy and I am sooo sorry for that how ever what I am trying to achieve should be able to be solved despite how messy my code is.
I want to be able to make it so that when a user types in the url www.example.com/embed-player/?mp3=SomeNewSong.mp3 it will replace the portion in my code which currently contains somemusicfile.mp3
for both of the locations it's currently in.
ok... if I got it. your code is a little confussing but I hope this can help you
you want to get song name from url and then put it in your resource variable, if that is right:
Use this:
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
and thens something like this:
//using this url www.example.com/embed-player/?mp3=SomeNewSong.mp3
//parameter is mp3 (query string)
resource["m4a"] = getURLParameter('mp3') || "somemusicfile.mp3";