Can I get iTunes to play like this?

Discussion in 'Mac Apps and Mac App Store' started by FreakinSyco, May 23, 2007.

  1. FreakinSyco macrumors regular


    May 3, 2007
    I love using my MacBook as a jukebox for the parties we have. I prefer to use the iTunes album art only mode. I would kill if I could get it to play like this:

    You select an album and it plays thru the songs on that album on shuffle then moves to the rest of the library on shuffle when its done.

    That way if someone wants to hear an album they can but it will keep going after that album is finished.
  2. macfaninpdx macrumors regular

    Mar 6, 2007
    Sounds like you can do this with an Applescript. I don't have a lot of scripting experience, but I am working on some similar iTunes scripts. Try something like the following:
    property myPlaylist : "Play One Album"
    tell application "iTunes"
    	set thisAlbum to album of selection
    	if not (exists (some user playlist whose name is myPlaylist)) then
    		set new_playlist to (make user playlist with properties {name:myPlaylist})
    		set new_playlist to user playlist myPlaylist
    			delete every track of new_playlist
    		end try
    	end if
    	duplicate (every track of library playlist 1 whose album is thisAlbum) to new_playlist
    	set shuffle of new_playlist to true
    	play new_playlist
    end tell
    on idle
    		tell application "iTunes"
    			if album of current track is not thisAlbum or player state is stopped then my back_to_shuffle()
    		end tell
    	on error
    		my back_to_shuffle()
    	end try
    	return 5
    end idle
    on back_to_shuffle()
    	tell application "iTunes"
    		set shuffle of library playlist 1 to true
    			play library playlist 1
    		end try
    	end tell
    end back_to_shuffle
    Select the text above and paste it into a new Script Editor document. Then save it in ~/Library/iTunes/Scripts/ and you should see it appear in the iTunes script menu.

    It works like this... while your library is playing you can move to a new song using the cover flow browser, or any other method in iTunes. Select the song (or album) you want, and run the script. It will create a new playlist (called "Play One Album") and try to copy all the tracks from your library with the same album as the selected track into this new playlist. If the playlist called "Play One Album" already exists, it will remove it's tracks first. Once it copies the tracks it should play the new playlist on shuffle.

    The on idle handler should check every 5 seconds. If the new playlist is done (either the track being played is from a different album or iTunes has stopped), it should return to shuffle on your entire library.

    Please use at your own risk, because I haven't really tested it, and I'm not sure what it will do if the selected track doesn't have an album. But with a little Applescript, you should be able to get it to do what you want.
  3. balamw Moderator


    Staff Member

    Aug 16, 2005
    New England
  4. macfaninpdx macrumors regular

    Mar 6, 2007
    I also just came across this script, which appears to work with Party Shuffle to accomplish what the OP is looking for.

Share This Page