Location: PHPKode > scripts > iTunes commander > itunes-commander/iTunes.class.php
<?php

/*	iTunes Commander
	using osascript (Applescript),
	running under Mac OSX.
	
	luruke.
 */

	class iTunes
	{
		
			//return the current song (song+artist)
			function nowplay($r = NULL)
			{
				$song 	= trim(`osascript -e 'tell application "iTunes" to name of current track as string'`);
				$artist = trim(`osascript -e 'tell application "iTunes" to artist of current track as string'`);
				
					return $r == 'song' ? $song : ($r == 'artist' ? $artist : array ('song' => $song, 'artist' => $artist) );	
			}
			
			//skip to next track
			function next()
			{
				`osascript -e 'tell application "iTunes" to next track'`;
				
				return 1;
			}
			
			//skip to previous track
			function prev()
			{
				`osascript -e 'tell application "iTunes" to previous track'`;
				
				return 1;
			}
			
			//set volume 0-100
			function volume($vol)
			{
				`osascript -e 'tell application "iTunes" to set sound volume to $vol'`;
				
				return 1;
			}
		
	}
	
?>
Return current item: iTunes commander