Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Queue an iTunes song after currently playing library song Apps
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.
    •    
  • Currently 4.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[24,284 views]  

Queue an iTunes song after currently playing library song | 22 comments | Create New Account
Click here to return to the 'Queue an iTunes song after currently playing library song' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Queue an iTunes song after currently playing library song
Authored by: DougAdams on Apr 20, '07 07:38:24AM

While this is neat and all, why not just use Party Shuffle? Right-click/Control click a track and choose "Add Next to Party Shuffle" from the menu.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: itrebax on Apr 20, '07 08:23:32AM

The point is to continue playing the currently playing song and then play the queued song after the currently playing song. If I forget to or don't use a playlist or party shuffle I don't believe this is possible. If it is I would love to know how to do it.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: acvh on Apr 21, '07 07:59:04AM
I made one change and this script fills a definite "want" for me. I hardcoded it to use the Party Shuffle, so now, if I'm listening to a tune from a "not Party Shuffle" playlist, and want to start up a PS session with a new song, without screwing up the active tune, I can use this script to copying the playing tune to PS, add the next tune and go off Party Shuffle browsing.

A minor thing, but the absence of this ability was an annoyance for me. I would forget that the active song wasn't in PS, add a new tune to PS, and the new one would start right up, sending the active song to the void.

[ Reply to This | # ]

Queue an iTunes song after currently playing library song
Authored by: Laner on Apr 24, '07 01:58:38AM

Please post the script you use. I would love to be able to move my playing song to Party Shuffle



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: itrebax on Apr 24, '07 08:16:15AM

Just change "Queue" to "Party Shuffle" or whatever playlist you want to use as a target.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: itrebax on Apr 24, '07 08:24:49AM
Although if you just want to move the currently playing track to party shuffle, you can use this simpler script.

tell application "iTunes"
	set queuePlaylist to playlist "Party Shuffle"
	if current playlist is not queuePlaylist then
		set curtrack to (duplicate current track to queuePlaylist)
		set playPosition to player position
		play curtrack
		set player position to playPosition
	end if
end tell


[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: Laner on Apr 24, '07 11:01:26AM

But what triggers at end of party shuffle or next in shuffle?



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: itrebax on Apr 24, '07 11:56:18AM

I don't understand your question.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: Laner on Apr 24, '07 11:58:39PM

When I run the script with "Party Shuffle" the song gets added to the end of the playlist. I would like one that adds the selected song as next in party shuffle.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: itrebax on Apr 25, '07 12:08:26PM
Have you seen the comments in this thread?

http://www.macosxhints.com/article.php?story=20040830035448525

[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: Laner on Apr 25, '07 12:28:06PM

Yes. But I use quicksilver. So I'm trying to make a script the will replace the "add to next" and "add to" options in Quicksilver. Because I'm not always in PArty Shuffle. So a script that does the same and moves the currently playing would be nice.



[ Reply to This | # ]
Bravo DOUG!
Authored by: sblowes on Apr 21, '07 08:52:49AM

Doug Adams is THE man when it comes to iTunes scripting... so it's pretty cool to see him suggest a built in feature when the hack is not necessary. You gotta be smart to code your own solutions... but smarter to know when not to code. Bravo, Doug.


---
To err is human, to moo is bovine



[ Reply to This | # ]
Since you are asking ...
Authored by: hamarkus on Apr 21, '07 11:40:59AM

... I never use Party Shuffle because it is essentially just another way of using the Shuffle function, which I have found no use for so far. (Admittedly, there is the added benefit of being able to see what is coming and to edit the list, but it is still useless for me.)

Firstly, this script creates a bonafide playlist, not some randomly selected mostly inappropriate list which I have to keep cleaning up, as Party Shuffle does.

Secondly, it has the elegance of being instant (current song is not interupted), of not cluttering up your source list when you don't need it (as Party Shuffle does), and of creating a playlist with a meaningful and configurable name.



[ Reply to This | # ]
Since you are asking ...
Authored by: BMarsh on Apr 23, '07 08:10:17AM

Party Shuffle can use any other playlist (including smart playlists) as a source... so the content in Party Shuffle is entirely configurable by you.

(with things like genre, BPM, "My Rating" features, you can fine tune the content in another Play List, then Party Shuffle itself adds the ability to add requests to the mix.)



[ Reply to This | # ]
Since you are asking ...
Authored by: hamarkus on Apr 23, '07 09:50:12AM

The main point of Party Shuffle is to make it possible to shuffle through a playlist and see what is coming up and edit the playing order yourself.

If you have a playlist that is small enough (to be homogeneous enough that you would want to use Shuffle) but also large enough (so even with Shuffle you don't always listening to the same songs), than Party Shuffle is very usefull. In other words, there is an operational window in terms of playlist (or more generally 'source') size for Party Shuffle, it just happens to be rather small for me.

However, this script is for ad-hoc playlists. Party Shuffle could be used for this by selecting an emply playlist as its source. Still, it would not have the elegance of this script: keep current song playing, accessible via shortcut, do not have both Party Shuffle and this empty playlist in the source pane when you don't need it.

To summarize: yes, Party Shuffle could be used for the purpose this script was written for (ad-hoc playlists) but it is not as elegant a solution.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: hypert on Apr 20, '07 09:42:49AM
Nice hint! And you write excellent AppleScript. I'm jealous. :-)

[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: hamarkus on Apr 20, '07 10:53:06AM

Wonderful hint, works marvellously. For those without Quicksilver, simply put the script in /Library/iTunes/Scripts and then assign via System Preferences -> Keyboard Shortcuts a shortcut for iTunes to the name you gave the script.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: jediknil on Apr 20, '07 09:20:45PM

Here's an updated version that handles queueing iPod tracks and queueing when no song is playing. And you don't need Quicksilver to assign a shortcut if you only want to use it in iTunes; just add it to iTunes' script menu (put the script in ~/Library/iTunes/Scripts) and use Apple's Keyboard Shortcuts (under Keyboard & Mouse in System Prefs).

Thanks for the original script, and for making it so easy to modify!

tell application "iTunes"
	set currentSource to container of view of front browser window
	if not (exists playlist " Queue" of currentSource) then
		set queuePlaylist to (make new user playlist 
			with properties {name:" Queue", shuffle:false} at currentSource)
	else
		set queuePlaylist to playlist " Queue" of currentSource
	end if
	set curtrack to {}
	if player state is not stopped then
		if current playlist is not queuePlaylist then
			delete tracks of queuePlaylist
			set curtrack to (duplicate current track to queuePlaylist)
		end if
	else
		delete tracks of queuePlaylist
	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
		set curState to player state
		play curtrack
		set player position to playPosition
		if curState is paused then pause
	else if tracks of queuePlaylist is not {} and (player state is stopped or current playlist is not queuePlaylist) then
		play first track of queuePlaylist
	end if
end tell


[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: itrebax on Apr 24, '07 11:53:18AM

I don't understand your question.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: itrebax on Apr 24, '07 11:55:55AM

Oops, this was meant to be a reply to Laner's question above.



[ Reply to This | # ]
Queue an iTunes song after currently playing library song
Authored by: morespace54 on May 22, '07 01:20:40PM

...or simply do a right-click and select "Add to Party Shuffle"



[ Reply to This | # ]
OUPS! Queue an iTunes song after currently playing library song
Authored by: morespace54 on May 22, '07 01:22:01PM

Same here...



[ Reply to This | # ]