<?php
////
//
// update.php
// Gets the current status from iTunes
//
// Copyright (c) 2006 Sean Healy, licensed under The BSD License
//
////
// $state = trim(shell_exec("osascript -e 'tell application \"iTunes\" to player state as string'"));
// $track = trim(shell_exec("osascript -e 'tell application \"iTunes\" to name of current track as string'"));
// $artist= trim(shell_exec("osascript -e 'tell application \"iTunes\" to artist of current track as string'"));
// $allInOne= trim(shell_exec("osascript -e '
// tell application \"iTunes\"
// set state to player state as string
// set trackName to name of current track as string
// set artistName to artist of current track as string
//
// return state & \"\n\" & trackName & \"\n\" & artistName
// end tell'"));
// $allInOne2= trim(shell_exec("osascript -e 'tell application \"iTunes\" to player state as string & \"\n\" & name of current track as string & \"\n\" & artist of current track as string'"));
$allInOne = trim(shell_exec("osascript ../appleScripts/getState.scpt"));
$allInOne = preg_replace("/\S\Sconstant\s\S\S\S\SkPSP\S\S/", 'playing', $allInOne);
// line 0: state(playing/paused)
// line 1: track
// line 2: artist
// echo $state."\n";
// echo $track."\n";
// echo $artist."\n";
echo $allInOne."\n";
// THIS IS RETARTED DON'T USE IT
// $i = 1;
// $r = " ";
// while($r != "")
// {
// $r = trim(shell_exec("osascript -e 'tell application \"iTunes\" to name of track ".$i." of current playlist as string'"));
// echo '<p>'.$r.'</p>';
// $i++;
// }
?>