Here's a neat way to control iTunes through the Internet. At home I'm usually using two computers; one small "couch laptop" and one desktop computer with my whole music library and a couple of decent loudspeakers. I found myself having to step up from the couch every time i had to either pause current track, adjust volume or skip songs. From my own laziness came the need for a simpler way to do this. I know there's other roads to remote iTunes control (see Signal), but I wanted to make this myself as a personal learning project while making the app exactly like I envisioned it.
Markup, styles, JavaScript, PHP scripts and graphics are all done by myself and I'm releasing it all here under a GNU General Public License.
Features
- Control song (play, pause, skip to next, skip to previous)
- Display info on current playing song with album art - click it to display fullsize
- Control iTunes (volume, shuffle, repeat)
- Display playlist with possibility to start a song by clicking its title
- Rating of current playing song
- Display current position in song
- Scroll to playing song in playlist by clicking song title in info panel
- Keyboard control:
- p/space = play/pause
- z = previous track
- x = next track
- + = volume up
- - = volume down
- s = toggle shuffle
- r = toggle repeat
- 1-5 = rate song
- Custom GUI for Mobile Safari (iPhone/iPod touch)
Weak points
- Browser support is limited to Opera, Firefox and Safari. tapTunes is still working in IE, but the GUI has some flaws.
- Too large playlists will take long to process and can make PHP time out. I'm generally using a playlist containing my 250 least played songs.
- The COM interface will not let you get current position in song, so this is generated client-side. May be somehow inacurate and loading tapTunes in the middle of a playing song will make progress bar start at 0:00.
- Playlist selection is not implemented (yet)
- There's no way to re-sort playlists from the GUI. These are currently sorted by Album by Artist by Track# by Disc# by Year.
Technology
PHP and COM
On Windows PCs (sorry, Mac) iTunes is available through a COM interface. If you have a correctly setup system, you can control iTunes through simple PHP code like:
<?php
// Instantiate a new COM client to iTunes
$iTunes = new COM('iTunes.Application');
// Skip to next track
$iTunes->NextTrack();
// Increase volume
$iTunes->SoundVolume += 10;
// Start/pause playing
$iTunes->PlayPause();
// Get current song title
$trackName = $iTunes->CurrentTrack->Name;
// Get name of currenttly showing playlist
$playlistName = $iTunes->BrowserWindow->SelectedPlaylist()->Name;
// Give current playing track three stars
$iTunes->CurrentTrack->Rating = 60;
?>
Quote from the PHP COM Documentation:
COM is an acronym for Component Object Model; it is an object orientated layer (and associated services) on top of DCE RPC (an open standard) and defines a common calling convention that enables code written in any language to call and interoperate with code written in any other language (provided those languages are COM aware).
I'm sure one can do similar stuff with AppleScript/shell commands on a Mac, so if you want to try, modify control.php, info.php and playlist.php and make your very own interface. :)
AJAX/JavaScript
AJAX functionality is implemented with the lightweight JavaScript framework mootools. I'm positive there's other frameworks at least as good, but mootools was coincidentally the one I know best.
Graphics
The graphics are made in Adobe Photoshop, ligtly inspired by another music player GUI. ;)
