« I don' t know anybody in canada... | Main | screwed the pooch? »

How to make your website display what your listening to in winamp

Ok, so yesterday I got a bug up my ass to see if I could make winamp display what I'm listening to on my website. My search to do this led me to a post in the winamp support forum by Elissaios who figured it out for his anime music station. After following his directions and getting the dosomething plugin to automatically update a file on my server every time the song changed with the ID3 information I set about figuring out how I could pull it into my site. SSI's aren't supported, and using MT's template to link to the file would only update every time I recompiled the database. So thankfully I was already using php, so I used a php include statement originally that GeekNJ found for me in the MT support forum:
<?php require("yourfile.txt"); ?>
But the problem with that (and the MT plugin idea) was that it didn't allow for formatting. I mean sure I could link the style sheet (css) but that doesn't do a lot of good if it's all dumped out on one line in a row. It looked bad...like this: Single Music Instructor Supersonic That wouldn't do. So thankfully Elissaios had answered my email asking how he got his formatting so nice and sent me the following code:
<?
$get = array(); // Specify the text file in the server eg: "np.inc"
$pointer = fopen ("np.inc", "r");
while (!feof ($pointer)) {
$record = fgets($pointer, 4096);
array_push($get,$record);
} // Assign lines from the TEXT file to variables for later use // The first line always starts from 0.
$txt_line_1 = $get[0];
$txt_line_2 = $get[1];
$txt_line_3 = $get[2]; // Here lets output the lines from the TEXT file
// Output the first line, eg the Artist
$txt_line_1; // Output the first line, eg the Title
$txt_line_2; // Output the first line, eg the Album
$txt_line_3;
?>
Following his directions I threw it in a *.php file on my server, and then pasted this code into my MT index template:
<div class="sidetitle">
Listening to:
</div>
<? include("playlist.php"); ?>
<font color="CC9933">Album:</font> <? echo $txt_line_1; ?><br>
<font color="CC9933">Artist:</font> <? echo $txt_line_2; ?><br>
<font color="CC9933">Song:</font> <? echo $txt_line_3; ?><br>
And as you can see the right, that's all there is to it. When winamp is off it usually says "broadcast stopped!". Next I plan on having something automaticallyy update every time I flush my toilet ;)

TrackBack

TrackBack URL for this entry:
http://www.dennisjudd.com/cgi-bin/mt-tb.cgi/573

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)