Archive for the ‘MIDI’ Category

Updated MIDI embedding method on DVD pages.

Wednesday, December 2nd, 2009

I’ve updated the method I’m using to embed MIDI files in my DVD pages that had them. A couple of example pages are The Best of Benny Hill and Star Wars I: The Phantom Menace. I am using the JavaScript method that is described at MIDIStudio.com. It’s basically the same thing I was doing before directly within the page’s code without JavaScript; however, this script now adjusts the code based upon the browser it detects which should make it more compatible.  I did modify their code slightly by adding an optional autostart parameter with a default value of 0 if no value is given so that it does not automatically start playing.  Here’s my modified code:

// This script determines correct code required to embed MEDIA files 
// for a large number of browsers, including AOL and WebTV
// Windows Media Player is required and always used, except for WebTV
// Written by Les Gorven, http://midistudio.com/ 
// Ver. 4.0 (simple) auto-start parameter is true - Created: February 2, 2008
// autostart parameter added by Mark Headrick December 2, 2009
 
function playMedia(mediaURL,rpt,height,width,autostart) {
var mediaURL,rpt,height,width,autostart;
 
if (typeof autostart == "undefined") {
	autostart = 0;
}
 
if (GetBrowser() == "IE")
	playAll(mediaURL,rpt,height,width,autostart) ;  
else if (GetBrowser() == "unknown")
	embedSource(mediaURL,rpt,height,width,autostart) ;
else if (navigator.appName.substring(0,5) == "WebTV")
	embedSource(mediaURL,rpt,height,width,autostart) ;
else
	playAll(mediaURL,rpt,height,width,autostart) ;
}
 
function embedSource(mediaURL,rpt,height,width,autostart) {
 
	var CodeGen = "";
	var mediaURL,rpt,height,width,autostart;
 
	CodeGen = '<embed src="' + mediaURL + '"' + '\n' ;
	if (autostart == 0) {
	 	CodeGen += ' height=' + height + ' width=' + width + ' autostart="false"' + '\n';
	} else {
		CodeGen += ' height=' + height + ' width=' + width + ' autostart="true"' + '\n';	
	}
	CodeGen += ' LOOP=' + rpt + '>';
	document.write(CodeGen);
}
 
function playAll(mediaURL,rpt,height,width,autostart) {
	var CodeGen = ""; 
 
	CodeGen = '<embed type="application/x-mplayer2" ' + '\n' ;
	CodeGen += ' pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" ' + '\n' ;
	CodeGen += 'Name="Player" ' + 'src="' + mediaURL + '" ' + '\n' ;
	CodeGen += 'autoStart=' + autostart + ' ' ;
	if ((height == 24) && (width == 299)) 
		CodeGen = CodeGen + 'ShowStatusBar=1 '; 
	if ((height >= 50) && (height <= 75) && (width >= 200)) 
		CodeGen = CodeGen + 'ShowStatusBar=1 '; 
	if ((height > 75) && (width >= 200)) 
		CodeGen = CodeGen + 'ShowStatusBar=0 '; 
	if ((height <= 49) && (width != 299))
		CodeGen += 'ShowStatusBar=0 '; 
	CodeGen += 'enableContextMenu=1 cache=0' + '\n' ;
	CodeGen += 'playCount=' + rpt + ' ' ;
	CodeGen += 'volume=-1 ' ;
	CodeGen += 'HEIGHT=' + height + ' WIDTH=' + width + '>' ;
	document.write(CodeGen);
}
 
function GetBrowser()
{
   var agt=navigator.userAgent.toLowerCase();
   if( ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) )
       return "IE";
   else if( ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
         && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
         && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) )
       return "Netscape";
   else
       return "unknown";
}

Within the page itself, I just put the following where I want the player to appear:

	<script type="text/javascript"> 
	playMedia("/midi/SomeFileToPlay.mid",3,65,300)
	</script>

If I want the song to automatically start playing, then I would change the code to:

	<script type="text/javascript"> 
	playMedia("/midi/SomeFileToPlay.mid",3,65,300,1)
	</script>

Seems to work well in both Firefox 3.5.5 and Internet Explorer 8. :)

Has hell frozen over? Website no longer using frames!

Saturday, December 15th, 2007

I have finally done it!!! My website is no longer using frames after years and years. It’s now using a combination of CSS and DIV containers to control the layout. I think I have made changes to all the pages and scripts that I needed to LOL. As you’ll notice, I no longer have my embedded midi player on the bottom left. Instead when clicking on a link to play a random midi file or any particular one, it will open a pop-up window with the midi player. Any future midi files will be targeted to that same pop-up window and start playing.

As a result of this, I have had to modify my .htaccess file to redirect any links that might be going to my old index.shtml (the file that contained my frame information) or main.php (which was the home page file loaded into the right-hand side) to just the root at “/” so that it loads the new index.php.

The main thing that is bugging me so far is that with Firefox, the pages that have an embedded object such as a media player, flash player, or YouTube player causes the left menu to be redrawn… except for the NASCAR page for some reason Confused. In IE, this does not happen. Trying to make things behave the same or as close to possibly can be a real pain sometimes. Anyway, now my website will be easier for search bots to handle and for people to bookmark and refresh pages! Big Grin

Blog has been updated to WordPress v2.2.3 and other changes.

Saturday, September 8th, 2007

I’ve updated my blog to WordPress v2.2.3 which includes a few security updates, a couple of which were high priority, and some bug fixes. Like before, I only updated the changed files. Since vars.php was one of the updated files, I did have to edit it and force the $is_apache variable to be true since on my server, the server_software variable comes back with WebServerX instead of Apache. Following is the part that I changed:

// Server detection
//$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;
$is_apache = true;

If I do not do this, then it will not modify the .htaccess file if I change the permalink structure.

I have also decided to reduce the possible annoyance factor when loading my website by not automatically playing the random MIDI file that is loaded into in the media player in the bottom-left frame. You now have to click play in order to hear the song. All other “play” links on the site will cause the player to automatically start playing.

I am aware that my site still uses those evil frames and how taboo it is these days to use them, not to mention the difficulties some search engines have with them. I’ll investigate my options… I just don’t like a seperate pop-up window, tab or browser to be created when clicking on a “play” link. It just makes browsing the site so.. disjointed. Hmmm.. :???:

Site performing normal again and some website updates.

Monday, August 20th, 2007

Well, the server seems to be behaving ok again. Haven’t seen the symptom again for two days now. Watch it happen again as soon as I post this, or tomorrow. LOL. Anyway, to make my main page more efficient, I am going to keep just including a static text file that contains my blog entries. I’ll only update that file when I actually update my blog.. like right after I make this post. My gallery image is still using the PHP Curl method. I also used to have separate log and counter scripts. I have combined both operations into the counter script in a more efficient way. I realized a better method of getting the actual referer (where a visitor to my webpage came from) which allowed me to get rid of the log script which was being called via an IMG tag. It’s a little tricky when using a framed website because the referer of the “main” page is always the “index” page that sets up all the frames and loads the menu, midi, and main frames. I am also now able to log the search bots as they visit my site. Normally, the search bots would not request my log script that was in an IMG tag. I also now save the count into a session variable so that it only counts a visitor once in a session.

In addition to all that, I have been playing around with Apache’s mod_rewrite and changed how my midi and some other items are handled so that now a normal looking link like http://www.markheadrick.com/midi/d/BeenThnk.mid is redirected to my midi database script for processing and the browser is none the wiser. Works better with search engines as well. Here’s what it looks like:

<ifmodule mod_rewrite.c>
RewriteEngine On
# BEGIN Midi
RewriteRule ^midi/d/([A-Za-z_0-9\)\(\-]*)\.mid$ php/mididb.php?action=download&id=$1.mid [L]
RewriteRule ^midi/d/([A-Za-z_0-9\)\(\-]*)\.kar$ php/mididb.php?action=download&id=$1.kar [L]
# END Midi
</ifmodule>

Well, I guess that’s about it as far as website updates go. :mrgreen:

Oh yeah, if you haven’t seen it, go see Bourne Ultimatum! That movie rocks!!!