iTunes anywhere.


The iTunesAnywhere server allows multiple clients to control the host installation of iTunes. This includes skipping tracks, changing the volume and selecting playlists. It also includes basic chat support. In short; you, and perhaps with some friends or colleagues, could use iTunesAnywhere to control your music library at home from your work using a web interface. iTunesAnywhere was developed in Java and uses COM calls to control iTunes. Therefore the server currently only runs on Windows platforms. Clients can however be platform independent. The server utilizes sockets for sending and receiving XML data(so-called XML socket server), thus clients can be developed in any language wich supports sockets and can do basic XML parsing. There will be a MacOSX compatible server in the near future.


To run the iTunesAnywhere server you will need the following software:


After installation just double click the startserver.bat file to get it running. The default port for iTunesAnywhere is 5150. This can be changed by specifying an alternative port as parameter on the commandline(eg: java -jar itunesanywhere.jar 8888) or by editing the startserver.bat file.


iTunesAnywhere only allows controlling iTunes, streaming is not supported out of the box but you can get some great results with a combination of the free icecast server and the m3w streamer. These tools allow you to capture incoming audio(if you have a full-duplex soundcard) and stream it to the web. They can be found at the following locations:

A tutorial which describes how to capture and stream incoming audio data(it uses the commercial simplecast instead of m3w) can be found here.

Client development guide.

iTunesAnywhere functions as a XML socket server. It expects a formatted XML message and returns one as response. If a track changes within the iTunes application it will fire an event and send the response to all clients. An example client request may look like the one below:

<message type="Volume" client="Joost">

This request tells the server to set the current volume at 20(%). The client attribute refers to the user's "chatname". Available client requests are:

Action Parameters Description
Play none Play or Pause the player
NextTrack none Advances to next track in current playlist.
BackTrack none Play previous track.
Volume numeric value(as percentage) changes volume
PlayList playlist id. changes to playlist wich corrensponds to the given id.
Shuffle true/false Set shuffle on/off for the current playlist.
Chat chatmessage Will broadcast a line of text to all connected clients. All iTunes information will be omitted from the server response.
GetUpdate none Returns current iTunes information. This request should only be made by stateless clients(such as PHP applications). Because iTunesAnywhere responds to player events noticable delays may occur in executing the action and updating the return message(see the PHP example).

A typical server response may look like the one below.

  <message>Joost requested next track</message>
    <artist>Aphex Twin</artist>
    <playlist id="5421">Library</playlist>
    <playlist id="11929">Partyshuffle</playlist>

Note the track section in the response. Among standard track info(artist, album, etc) it holds the total playtime of the track( MM:SS ) and the current position of the playhead in milliseconds. This allows you to program a track progressbar of some kind.

This, of course, will only work if you have successfully set up a socket connection with the iTunesAnywhere server. Something that is particularly easy to do within Macromedia Flash. A very rudimentary example Flash client is in the download section, check it out! Below is an example php5 script that communicates with the iTunesAnywhere server to change the track.

//open a socket to the server. do not use persistant sockets here.
$socket = fsockopen( "", "5150" );

//We will request a next track.
$action = "<message type=\"NextTrack\" client=\"Joost\"><param /></message>";

//request the action.
fwrite($socket, $action);
$rval = fread($socket, 3072);

//get the returned xml and use simpleXml to parse the string.
$rval = fread($socket, 3072);
$oXml = simplexml_load_string( $rval );

//echo the data from the recieved XML; 
echo "Artist: " . $oXml->track->artist . "<br />";
echo "Track: " . $oXml->track->track . "<br />";
echo "Album: " . $oXml->track->album; 

//close socket

I encourage you to develop your own clients. If they are any good, drop me a line and I will put them in the download section.

Some notes about the server.

Feel free to use or modify the server for your own projects. The server uses some royalty free opensource library’s namely: JDOM for XML generation and parsing, and JACOB for making the COM calls (make sure to copy jacob.dll to the system32 directory)to iTunes. Both are includes within the iTunesAnywhere distribution. Feel free to ask me anything regarding the source code.

Maintained by Joost Verrijt(

If you have any questions regarding bugs, raves, rants, feature requests, cash donations etc or if you want to contribute to the iTunesAnywhere project, send me an email.

Valid XHTML 1.0 Strict Logo