NetRyder
Tech Junkie
- Joined
- 19 Apr 2002
- Messages
- 13,256
Now Playing Script for Windows Media Player 9
This is a text-based version for use on your own webpage. An image-based version for use on forums etc. will follow later. (Last Updated: Sept. 18, 2003)
1. Download the ZIP file attached to the next post, and run the setup file. This will install the Songwriter plugin to the WMP9 plugins folder (C:\Program Files\Windows Media Player\plugins\)
2. Open WMP9 and click Tools>Options. Switch to the "Plugins" tab, and select Background from the plugins list. Make sure "Songwriter Plugin" is checked.
3. Select the "Songwriter Plugin" and click Properties. You should see a dialog box that looks like the one in the attached image. Enter the details as shown in the image.
(This tutorial only covers the Artist and Title, so check only those two boxes. The code below can be modified to incorporate other details as well). Click OK and close WMP9.
4. Copy and paste the following code into a text editor, and save the file as nowplaying.php (No changes are required to the code)
nowplaying.php
Code:
<?php
$songfilename = 'songout.txt';
$songfile = fopen($songfilename, "r");
$artist = trim(fgets($songfile));
$song = trim(fgets($songfile));
fclose($songfile);
$last_update = date ("U", filemtime('songout.txt'));
/* This check prevents junk characters from printing
* when the stop button is pressed due to a bug in SongWriter */
if(strstr($artist,"+"))
print "No music playing";
else {
// No music playing if no updates in the last 10 minutes
if($last_update < time()-600)
print "No music playing";
else
print $artist." - ".$song;
}
?>
5. Upload nowplaying.php to the same folder as the one you entered in the SongWriter config dialog box.
6. Now fire up WMP9, and play your favorite tune. The file songout.txt will automatically be updated with the song details. You can now use the include() function to display the currently playing song anywhere on your webpage. For example:
index.php
Code:
<html>
<head><title>Test Page</title></head>
<body>
Page Content Page Content Page Content Page Content Page Content Page Content
Page Content Page Content Page Content Page Content Page Content Page Content
Page Content Page Content Page Content Page Content Page Content Page Content
<br />
Now Playing: <?php include('nowplaying.php'); ?>
<br />
Page Content Page Content Page Content Page Content Page Content Page Content
Page Content Page Content Page Content Page Content Page Content Page Content
Page Content Page Content Page Content Page Content Page Content Page Content
</body>
</html>