Today I was trying to organise my iTunes library, making playlists, rating songs, etc. As I do this, I usually like to listen to some music. As a playlist or Party Shuffle is playing in the background, I sometimes would like to play just a little bit of a song to remind myself of how it goes, to help decide how I'm going to rate it. However, this always means either stopping the song that's playing, or waiting until it ends and then possibly forgetting what I wanted to play a sample of in the first place.
So today I wrote the following AppleScript that I then placed in the iTunes script folder (~/Library » iTunes » Scripts), which makes it accessible from the script menu in iTunes:
tell application "iTunes"
set currentTrack to current track
set playPosition to player position
set theSampleTrack to selection
play selection
set player position to 50
display dialog "Sampling Track. Click Stop to revert to the previously playing track" buttons {"Stop"}
if button returned of the result is "Stop" then
play currentTrack
set player position to playPosition
end if
end tellMac OS X Hints
http://hints.macworld.com/article.php?story=20070313124851912