External Audio Player Help PLEASE!

+1 Gavin Lee · August 11, 2015
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 with SomeNewSong.mp3 

 for both of the locations it's currently in.

Post a Reply

Replies

Oldest  Newest  Rating
0 Brotsky Tv · August 21, 2015
Try this code:

<head>
<script type="text/javascript">
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
title: "Bubble",
m4a: "http://www.jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
oga: "http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
});
},
cssSelectorAncestor: "#jp_container_1",
swfPath: "/js",
supplied: "m4a, oga",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true
});
});
</script>
</head>
Take care to include the jPlayer JavaScript code after the jPlayer plugin is included in your page.
Your <head> code should look like:
<head>
<link type="text/css" href="/dist/skin/pink.flag/css/jplayer.pink.flag.min.css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.jplayer.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
title: "Bubble",
m4a: "http://www.jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
oga: "http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
});
},
cssSelectorAncestor: "#jp_container_1",
swfPath: "/js",
supplied: "m4a, oga",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true
});
});
</script>
</head>



For more Javascript tutorials :--->  www.brotsky.tv/category/javascript/
  • 1

Javascript

106,936 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators