View Single Post
Old 10th May 2006, 22:51   #370
osmosis
Major Dude
 
osmosis's Avatar
 
Join Date: Jan 2006
Location: Cananada
Posts: 841
alexrussell: get the newest CVS revision of gen_activewa.dll from the sourceforge page and see if that fixes your problem. I've had no trouble with the ChangedTrack event.

anyone: since i have pretty much no knowledge of scripting and i just scrapped/hacked this together out of a couple other scripts with some minor ingenuity of my own, i was hoping that someone could look at my script and see if everything makes sense. please and thank you in advance to anyone who's willing.

playlist_Party Shuffle (15).vbs:
PHP Code:
' +--------------------------------------------+ 
|    Party Shuffle 2.0 (15 track version)    | 
' +--------------------------------------------+ 
Automatically enqueues a new random song each time another is played
' An ActiveWinamp script brought to you by osmosis and neFAST. 

Changes1Can be triggered via the Script menu
'          2) Start with base # of current items (builds the backlog as it goes, as per iTunes). 
'          
3On track changemaintains PL item total if any have been removedskippedetc
'             (note: iTunes updated automatically on remove but AW has no support for PL events). 
'          
4Randomization now includes all artists
'          5) Playlist now definitely contains only audio items. 
'          
6Dialog on launch to choose whether to clear the playlist
'          7) Script quits when playback is completely stopped. 
'          
8Switched to a Scripting Dictionary for faster querying and randomized loading

' Todo: 1) Weighted shuffling (in 3.0). 

May 102006 

Dim mlq
,i,j,Dict1,keys,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") 

if startup=2 then 
   ' 
abort if requested 
   quit 
end 
if 

' clear PL if desired 
if startup=6 then 
   playlist.clear 
end if 

more inclusive
mlq MediaLibrary.RunQueryArray("type=0"


For each track in mlq 
   Dict1
(track.artist)=Dict1(track.artist) + ":" CStr(i
   

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) 
   Rand = Int(Dict1.Count*Rnd+1) 
   idxs = Split(itms(Rand), ":", -1, 1) 
   Rand2 = CInt(idxs(Int(ubound(idxs)+1 * Rnd))) 
   mlq(Rand2).enqueue 
Loop 

if startup=6 then 
   ' 
Now let's play 
   play 
end if 

Sub Application_ChangedTrack 

if playlist.position>6 then 
   ' 
We delete however many the PL position has changed by 
   pos
=playlist.position-
   pchg
=
   
Do while (pos>pchg
      
playlist.deleteindex(1
      
pchg=pchg+
   Loop 

end 
if 

if 
playlist.count<=(playlist.position+8then 
   
' 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)) 
      
Rand Int(Dict1.Count*Rnd+1
      
idxs Split(itms(Rand), ":", -11
      
Rand2 CInt(idxs(Int(ubound(idxs)+Rnd))) 
      
mlq(Rand2).enqueue 
   Loop 
   
end 
if 

End Sub 

Sub Application_ChangedStatus 

if PlayState=0 then 
   
' exit if state has changed to stopped 
   quit 
end if 

End Sub 
osmosis is offline   Reply With Quote