Author: osmosis
Winamp Party Shuffle 3.2+ (with weighted shuffling!) is located as “Biased Party Shuffle” here.
playlist_Party Shuffle (15).vbs:
' +--------------------------------------------+ ' | Party Shuffle 2.8 (15 track version) | ' +--------------------------------------------+ ' Automatically enqueues a new random song each time another is played. ' An ActiveWinamp script by osmosis, based on Party Shuffle by neFAST. ' Changes: 1) Can be triggered via the Script menu. ' 2) Starts with correct base # of items (builds the backlog as it goes, as per iTunes). ' 3) On track change, maintains PL item total if any have been removed, skipped, etc. ' (note: iTunes updated automatically upon removal but AW has no support for PL events). ' 4) Randomization now includes all artists and is audio only. ' 5) Script quits when playback is completely stopped. ' 6) Dialog on launch to choose whether to clear the playlist. ' 7) Switched to a Scripting Dictionary for faster querying/randomized loading. ' 8) Caches previously enqueued songs to stop repeats (thanks to MarquisEXB). ' 9) Logs user added tracks in the song cache (thanks to vect). ' 10) Fixed Rand out of bounds error (thanks to Anreal). ' Todo: 1) Weighted shuffling (in 3.0). ' Known Issues: 1) Due to the way in which Nullsoft Tray Control 2.0 gets the currently playing ' track info, it can get confused after track changes and display incorrectly ' when in compact mode. ' 2) Editing a playlist entry or ID3 tag during a track change results in the edited ' track/entry replacing the one in the position it occupied before the change. ' Feruary 1, 2007 (osmosis) Dim mlq,i,j,Dict1,keys,SongHistory,startup,idxs,pos,pchg Set Dict1 = CreateObject("Scripting.dictionary") Dict1.CompareMode = BinaryCompare ' This is the first launch startup=MsgBox("Start new Party Shuffle playlist?",_ vbYesNoCancel+vbDefaultButton2+vbQuestion,"Winamp Party Shuffle (15 track)") ' abort if requested if startup=2 then quit end if ' clear PL if desired if startup=6 then playlist.clear else Safety=0 For i = 1 to playlist.count OR Safety > 10000 Safety=Safety+1 Call AddSong(playlist.item(i).DBindex) next end if ' hangs a little at runtime, but faster overall. mlq = MediaLibrary.RunQueryArray("type=0") i = 1 For each track in mlq ' First entry without ":" if Dict1(track.artist)="" then Dict1(track.artist) = CStr(i) else Dict1(track.artist) = Dict1(track.artist) + ":" + CStr(i) end if i = i + 1 next Randomize itms = Dict1.Items ' fill the PL if needed (up to 10, any others will be added on track change) Do while (playlist.count<=9) Call GetTracks Loop ' Now let's play (if new PL, otherwise it's up to the user) if startup=6 then play end if Sub GetTracks Safety=0 Do Safety=Safety+1 Rand = Int(Dict1.count*Rnd) idxs = Split(itms(Rand), ":", -1, 1) Rand2 = CLng(idxs(Int((ubound(idxs)+1)*Rnd))) Loop until (instr(SongHistory,mlq(Rand2).DBindex & ":")=0) OR Safety > 10000 mlq(Rand2).enqueue Call AddSong(mlq(Rand2).DBindex) End Sub Sub AddSong(SongNumber) SongHistory = SongHistory & SongNumber & ":" End Sub Sub Application_ChangedTrack ' detect tracks manually added to the playlist and logs them in the history Safety=0 For i = playlist.position to playlist.count OR Safety > 10000 Safety=Safety+1 if not (instr(SongHistory,playlist.item(i).DBindex & ":")=0) then Call AddSong(playlist.item(i).DBindex) end if next if playlist.position>6 then ' We delete however many the PL position has changed by pos=playlist.position-6 pchg=0 Do while (pos>pchg) playlist.deleteindex(1) pchg=pchg+1 Loop end if if playlist.count<=(playlist.position+8) then ' We add songs until there's a backlog of 5 (startup) ' or until we've reached 15 again Do while (playlist.count<=(playlist.position+8)) Call GetTracks Loop end if End Sub Sub Application_ChangedStatus if PlayState=0 then ' exit if state has changed to stopped quit end if End Sub