Queue an iTunes song after currently playing library song

Apr 20, '07 07:30:00AM

Contributed by: itrebax

I am a recent switcher and former Winamp user. I missed the 'q' button to queue up the selected track after the currently playing track without using playlists. This script emulates that behavior by adding the currently playing and selected tracks to a playlist, and resuming at the correct position in the playlist:

tell application "iTunes"
  if not (exists playlist "Queue") then
    set queuePlaylist to (make new user playlist ¬
     with properties {name:"Queue", shuffle:false})
  else
    set queuePlaylist to playlist "Queue"
  end if
  if current playlist is not queuePlaylist then
    set curtrack to (duplicate current track to queuePlaylist)
  else
    set curtrack to {}
  end if
  if selection is not {} then
    set sel to a reference to selection
    duplicate sel to queuePlaylist
  end if
  if curtrack is not {} then
    set playPosition to player position
    play curtrack
    set player position to playPosition
  end if
end tell
This helps out a lot when I forget to make a playlist. If the playlist is already being used, then the script just adds the selected track to the end of the queue playlist. I have this script assigned to a Quicksilver trigger and it works great, but there is a small skip in the audio when the currently playing track is resumed in the playlist.

Comments (22)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070419104324966