View Single Post
Old 18th February 2006, 19:35   #329
MarquisEXB
Junior Member
 
Join Date: May 2005
Posts: 23
This script goes through every song in your playlist** and notes the artist. It then runs through & repopulates the playlist with the first song from each artist. Then it enqueues the second (if any) song from each artist, and so forth.

One application of this is if you want to listen to 10 or 20 different albums, but don't want to hear any song by the same artist twice in a row (until the very end). You may want to enqueue 20 albums from different artists & randomize it, because if not you'll hear every first song on the albums first, then all the second songs on each album, etc.

Another use for this is if you make a playlist with a few random collections, but you don't want to hear the same artist twice in a row.

** (I used x = playlist.getselection(), because I don't know how to get the entire playlist).

playlist_Dupe_Artist_Move

PHP Code:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Select **ALL** the songs in your playlist
'
This will reorder ittaking any songs
' by duplicate artists & move them to the end.
'
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim x
x = playlist.getselection()
playlist.clear

Set Dict1 = CreateObject("Scripting.dictionary") 
Dict1.CompareMode = BinaryCompare 
i=1 ' 
i is the number of each treack

for each track in x
Dict1
(ucase(track.artist))=Dict1(ucase(track.artist)) & vbcrlf cstr(i)
i=i+1
next

i
=' now i represents the number of times to go through the array

do 
    EndLoop=TRUE
    i=i+1

    for each Songs in Dict1.Items 

    if ubound(split(songs,vbcrlf)) >= (i)  then 
        EndLoop=FALSE
        x(split(songs,vbcrlf)(i)).enqueue
    end if

    next    '
for each Songs in Dict1.Items 

' set sep = LoadItem("X:~~ " & i  & " ~~~~~~~~~~~~~~")
sep.insert(playlist.count)

loop until EndLoop or 100000 ' failsafe


quit 
MarquisEXB is offline   Reply With Quote