Hi guys, I managed to make a nifty little website site with which to control my iTunes using php and applescript. The way it’s setup I can access this site from my blackberry and control my music from anywhere in my house / the world.
As of right now the script serves only to play / pause the track, previous track, next track, volume up or down, and display the song name and artist. I have been unsuccessful as of yet to find anymore commands for iTunes which can be executed to increase the functionality. My ultimate goal would be to be able to search for and choose songs, choose different playlists, etc.
If anybody happens to know a whole bunch of commands which can be executed using osascript -e which could help me increase functionality that would be fantastic. For those interested here is the current php script I am using.
[code]
iTunes Controller <?php
$q = $_GET['q'];
switch ($q)
{
case "play";
exec("osascript -e 'tell app \"iTunes\" to play'");
break;
case "pause";
exec("osascript -e 'tell app \"iTunes\" to pause'");
break;
case "playpause";
exec("osascript -e 'tell app \"iTunes\" to playpause'");
break;
case "next";
exec("osascript -e 'tell app \"iTunes\" to next track'");
break;
case "prev";
exec("osascript -e 'tell app \"iTunes\" to previous track'");
break;
case "louder";
exec("osascript -e 'tell app \"iTunes\" to set sound volume to sound volume + 5'");
echo "Turning Up the Volume...";
break;
case "quieter";
exec("osascript -e 'tell app \"iTunes\" to set sound volume to sound volume - 5'");
echo "Turning Down the Volume...";
break;
}
?>
<img src="logo.png" alt="iTunes Controller" /><br />
<div id="center">
<hr />
<a href="index.php?q=prev"><img src="prev.png" alt="Previous" /></a>
<a href="index.php?q=playpause"><img src="play.png" alt="Play / Pause" /></a>
<a href="index.php?q=next"><img src="next.png" alt="Next" /></a>
<?php
$song = exec("osascript -e 'tell app \"iTunes\" to name of current track as string'");
$artist = exec("osascript -e 'tell app \"itunes\" to artist of current track as string'");
if ($song != "" || $artist != "") {
echo '<p><strong>' . $song . '</strong><br />' . $artist . '</p>';
} else {
echo '<p><em>No Song Playing</em></p>';
}
?>
</div>
</body>
[/code]
Model: Macbook
Browser: Firefox 3.0.3
Operating System: Mac OS X (10.5)