Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
Bayoujack
New Member
New Member


Joined: Dec 04, 2005
Posts: 12

PostPosted: Thu Apr 27, 2006 12:40 am Reply with quote

I've been searching for a way to add background music that will work with most browsers (user controls of course).

The Flam Player works well for a separate page, but doesn't look good when down sized. The best I've found so far is here: Only registered users can see links on this board! Get registered or login!. I'm not sure what file to add the javascript sections to though.
It would be nice as a module or addon. What do you think? Confused
 
View user's profile Send private message
CodyG
Life Cycles Becoming CPU Cycles


Joined: Jan 02, 2003
Posts: 712
Location: Vancouver Island

PostPosted: Thu Apr 27, 2006 1:19 am Reply with quote

I'm always looking for ways to improve my understanding of how code works. Making that code easier on the user is all good too. So thanks for the link to howtoplaysound.htm. It is one of the clearest tutorials on adding music to webpages I've ever encountered.

After viewing the source of the example page I think the following would work.

Step 1.

The js functions need to be in a head tag. In nuke define the js functions in the includes/javascript.php file.

Code:


<scr ipt language="JavaScript" type="text/javascript">
function getMimeType(){
var  mimeType = "application/x-mplayer2"; //default
var agt=navigator.userAgent.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
with (navigator){
 if (mimeTypes && !(agt.indexOf("windows")!=-1 && agt.indexOf("windows 3.1")==-1)) {
 //non-IE, no Windows
   var plugin = mimeTypes["audio/mpeg"].enabledPlugin;
   if (plugin) mimeType = "audio/mpeg"    //mac/Safari
/*   else {
      plugin = mimeTypes["audio/mpeg-url"].enabledPlugin;
      if (plugin) mimeType = "audio/mpeg-url" // non-IE 2nd favorite (Linux/FF)
   }
*/
 }//end no-Windows
}//end with (navigator)
return mimeType
}//end function getMimeType

function setEmbed(ID, root){
    var element = document.getElementById(ID);
   element.innerHTML ='<embed src="'+root+ID+'.m3u" autostart="0" loop="0" height="45" width="170" type="'+getMimeType()+'"></embed>';
}// end function setEmbed
</scr ipt>


Step 2.
Then you need to call the onload=path/to;setEmbed functions in the body tag, found in your theme.php. However, this is where it gets complicated because blocks and modules don't usually have body tags.
But apparently you can do anything with php and css. Smile

Code:
<body bgcolor="white" onload=

"root='http://www.juancarlosproductions.com/music/';setEmbed('mystagogia',root);setEmbed('CanyonMan',root)">


Step 3.
To actually get the player on the webpage you need to call the id in the span tag.
Code:


<span id="mystagogia">Finding plugin...</span> &nbsp; &nbsp; <span id="CanyonMan">Finding plugin...</span>


I haven't actually tried this, but I've saved the instructions and sample source and when I get some time... If you try it, do post your results.

_________________
"We want to see if life is ubiquitous." D.Goldin 
View user's profile Send private message
Bayoujack
PostPosted: Fri Apr 28, 2006 10:24 am Reply with quote

I having trouble with #2, calling the onload=path/to;setEmbed functions in the body tag, in theme.php. I think it's time for a coffee break.
 
CodyG
PostPosted: Fri Apr 28, 2006 11:08 am Reply with quote

I think the onload needs to be called from your block or module file ... I only used theme.php as an example as how the embed tag is enabled in the body tag.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©