NetRyder
Tech Junkie
- Joined
- 19 Apr 2002
- Messages
- 13,256
Ever since I switched to iTunes from WMP9, I've missed the ability to display my currently playing song online. The SongWriter plug-in could do this easily for WMP9 (I had a tutorial up for this before we lost our database), but there's no such direct plugin for the Windows version of iTunes yet. I've finally figured out a way to do it...
"localhost" from the Aqua-Soft forums has recently released a plugin that enables iTunes to dump the details of the currently playing song to a text file on the local disk. This tutorial extends the ability of the plugin, so that you can use it almost like the SongWriter plugin for WMP9, and other such plugins for Winamp etc.
Your server MUST support PHP in order for this to work
NOTE: Other plugins that send information to the server directly are able to update the currently playing song realtime on the server. The method in this tutorial does not work the same way. The details of the currently playing song will be updated depending on how often you set XP's Task Scheduler to poll the server. Read on...
1) Download the iTunes Multi-plugin by localhost from here:
http://www.aqua-soft.org/board/index.php?showtopic=10678&view=findpost&p=115689
UnRAR the MPlugin.dll file into your iTunes plugin folder (ex: C:\Program Files\iTunes\plugins)
2) Open iTunes, right click the titlebar, and select Options. Check the "Create a file in the iTunes folder..." box.
To test that the plugin works as intended, play any song in your library and look for the file CurrentSong.txt in your iTunes folder. It should contain the details of the song that is playing.
3) Download RunH from here, and unzip the runh.exe file in your iTunes folder.
http://www.scripthorizon.com/library/utilities/runh.zip
The purpose of runh is to hide the command prompt window that pops up when the Task Scheduler runs the batch file that uploads the text file to your server.
4) You need two more files in your iTunes folder - we'll name them upload.bat and ftp.txt
Modify them according to the specific details for your server.
upload.bat
ftp.txt
NOTE: path_to_folder is the name of the folder you want to store the text file in. In my case, for example, it is "public_html"
5) Now we create a task using XP's Task Scheduler, so that this batch file runs every 5 minutes and uploads the text file to the server. Open Control Panel and double click Scheduled Tasks. Then select "Add Scheduled Task"
- In the wizard, click Browse and select the runh.exe file you placed in your iTunes folder. Select "Daily" and set the Start Time to whenever you would like the task to start running. I set mine to 8:00 AM. Enter the password for your XP user account when prompted. Check the advanced properties box, and click Finish.
- Now you should see the advanced configuration dialog box. Change the path in the "Run" box to exactly "C:\Program Files\iTunes\runh.EXE" "upload.bat" (including the quotes)
- In the Schedule tab, click Advanced, and check "Repeat Task." For the "Every" option select the time intervals at which you want the task to run. This will be the frequency at which the file on your web server will be updated. For the "Until" option, select Time, and set it to the time you want the task to stop. Mine is set to 11:59 PM
- Hit OK until all the dialog boxes close. This step is now complete.
6) Create a file called nowplaying.php and add the following lines to it:
Upload this file to the same folder on your server that contains CurrentSong.txt
You're all set. Point your browser to nowplaying.php to see what it looks like. You can now add this to any other page using:
"localhost" from the Aqua-Soft forums has recently released a plugin that enables iTunes to dump the details of the currently playing song to a text file on the local disk. This tutorial extends the ability of the plugin, so that you can use it almost like the SongWriter plugin for WMP9, and other such plugins for Winamp etc.
Your server MUST support PHP in order for this to work
NOTE: Other plugins that send information to the server directly are able to update the currently playing song realtime on the server. The method in this tutorial does not work the same way. The details of the currently playing song will be updated depending on how often you set XP's Task Scheduler to poll the server. Read on...
1) Download the iTunes Multi-plugin by localhost from here:
http://www.aqua-soft.org/board/index.php?showtopic=10678&view=findpost&p=115689
UnRAR the MPlugin.dll file into your iTunes plugin folder (ex: C:\Program Files\iTunes\plugins)
2) Open iTunes, right click the titlebar, and select Options. Check the "Create a file in the iTunes folder..." box.
To test that the plugin works as intended, play any song in your library and look for the file CurrentSong.txt in your iTunes folder. It should contain the details of the song that is playing.
3) Download RunH from here, and unzip the runh.exe file in your iTunes folder.
http://www.scripthorizon.com/library/utilities/runh.zip
The purpose of runh is to hide the command prompt window that pops up when the Task Scheduler runs the batch file that uploads the text file to your server.
4) You need two more files in your iTunes folder - we'll name them upload.bat and ftp.txt
Modify them according to the specific details for your server.
upload.bat
Code:
@echo off
ftp.exe -s:"ftp.txt"
exit
ftp.txt
Code:
o ftp.yourhost.com
your_username
your_password
cd path_to_folder
ascii
put C:\"Program Files"\iTunes\CurrentSong.txt
quit
5) Now we create a task using XP's Task Scheduler, so that this batch file runs every 5 minutes and uploads the text file to the server. Open Control Panel and double click Scheduled Tasks. Then select "Add Scheduled Task"
- In the wizard, click Browse and select the runh.exe file you placed in your iTunes folder. Select "Daily" and set the Start Time to whenever you would like the task to start running. I set mine to 8:00 AM. Enter the password for your XP user account when prompted. Check the advanced properties box, and click Finish.
- Now you should see the advanced configuration dialog box. Change the path in the "Run" box to exactly "C:\Program Files\iTunes\runh.EXE" "upload.bat" (including the quotes)
- In the Schedule tab, click Advanced, and check "Repeat Task." For the "Every" option select the time intervals at which you want the task to run. This will be the frequency at which the file on your web server will be updated. For the "Until" option, select Time, and set it to the time you want the task to stop. Mine is set to 11:59 PM
- Hit OK until all the dialog boxes close. This step is now complete.
6) Create a file called nowplaying.php and add the following lines to it:
Code:
<?php
$fname = "CurrentSong.txt";
$songfile = fopen($fname, "r");
$artist = fgets($songfile);
if($artist != " ") {
$track = fgets($songfile);
echo "iTunes: ".$artist." - ".$track;
}
else
echo "iTunes: No Song Playing";
fclose($songfile);
?>
You're all set. Point your browser to nowplaying.php to see what it looks like. You can now add this to any other page using:
Code:
<?php include('nowplaying.php'); ?>