Writing /home/myplugin/public_html/activewinamp/data/cache/3/3025726005fd316e9ca437db7623c9f0.i failed
Writing /home/myplugin/public_html/activewinamp/data/cache/3/3025726005fd316e9ca437db7623c9f0.i failed
Writing /home/myplugin/public_html/activewinamp/data/cache/3/3025726005fd316e9ca437db7623c9f0.xhtml failed

Generate a rolling 'weighted party shuffle' playlist from a smartview

Author: anreal

sendto_Smartview Weighted Party Shuffle (20).vbs:

'Smartview SendTo Weighted Party Shuffle v2, 20 Track
'by anreal, based on osmosis Winamp Party Shuffle v2.6
 
Dim mlq,Dict1,keys,idxsOfArtistTracks,mlqHystory
 
Set Dict1 	= CreateObject("Scripting.dictionary") 
 
'Max value of hystory viewing
WeightParam 	= 160
 
'Initial number of days for hystory view
d 		= 14
 
HystoryLimit = WeightParam*1.25
 
SafetyLimit 	= 200
 
Dict1.CompareMode = BinaryCompare 
 
' This is the first launch 
startup=MsgBox("Start new Party Shuffle playlist?",_ 
        vbYesNoCancel+vbDefaultButton2+vbQuestion,"Smartview Party Shuffle") 
 
' abort if requested 
if startup=2 then 
   quit 
end if 
 
' clear PL if desired 
if startup=6 then 
   playlist.clear 
end if 
 
' default to whole library if no items selected
if isNull(GetSendToItems) then
   mlq = GetSendToItems
else
   mlq = MediaLibrary.RunQueryArray("type=0")
end if
 
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 
 
itms = Dict1.Items
 
Randomize
 
'Make the number of Hystory view tracks closer to the HystoryLimit
Do While d > 1
  mlqForHystory 	= MediaLibrary.RunQueryArray("lastplay > ["+cstr(d)+" days ago]")  
  if ubound(mlqForHystory) < HystoryLimit then Exit Do
  d = d - 1
loop
 
' fill the PL if needed (up to 15, any others will be added on track change) 
Do while (playlist.count<=14) 
   Call FindedTrack
Loop 
 
' Now let's play, if new PL (otherwise it's up to the user) 
if startup=6 then 
   play 
end if 
 
Sub FindedTrack
 
Safety 			= 0 
 
Do 
   result 		= 0	
   Safety		= Safety + 1 
   'Generate random number from 0 to Dict1.count-1
   RandArtist 		= Int(Dict1.count*Rnd) 
   'List of all artist tracks
   idxsOfArtistTracks 	= Split(itms(RandArtist), ":", -1, 1) 
   'Generate random number from 1 to ubound(idxsOfArtistTracks)
   ArtistRandTrackNum	= Int((ubound(idxsOfArtistTracks)+1)*Rnd)
   GlobalRandTrackNum	= CLng(idxsOfArtistTracks(ArtistRandTrackNum)) 
   'for ***** rating same song accepted every WeightParam/32 time,
   'for * rating same song accepted every WeightParam/1 time 
   trackRatingWeight	= WeightParam/Exp(mlq(GlobalRandTrackNum).rating*Log(2))
 
   'Searching a new track in the playlist tracks
   j = playlist.count
   do while (j >= playlist.position) AND (playlist.count-j <= trackRatingWeight)
     if playlist.item(j).title = mlq(GlobalRandTrackNum).title then
        result = 1
	Exit Do
     end if
     j = j - 1
   loop
 
   'Searching a new track in the hystory
   i = 1
   do while ((playlist.count-j+i) <= trackRatingWeight) AND (i <= ubound(mlqForHystory))_
            AND (result <> 1)
      if mlqForHystory(i).title = mlq(GlobalRandTrackNum).title then   
         result = 1
	 Exit Do
      end if
      i = i + 1 
   loop 
'if a new track isn't played, or enqueued then we add him in the playlist
Loop until (result = 0) OR  (Safety > SafetyLimit)
 
mlq(GlobalRandTrackNum).enqueue 
 
End Sub
 
Sub Application_ChangedTrack 
 
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+13) then 
   'correction the numbers of tracks stored in hystory of played tracks
   mlqForHystory 	= MediaLibrary.RunQueryArray("lastplay > ["+cstr(d)+" days ago]")  
   if ubound(mlqForHystory) < WeightParam then
      d = d + 1
      mlqForHystory 	= MediaLibrary.RunQueryArray("lastplay > ["+cstr(d)+" days ago]")  
   end if
   if (ubound(mlqForHystory) > HystoryLimit) AND (d > 0)then
      d = d - 1
      mlqForHystory 	= MediaLibrary.RunQueryArray("lastplay > ["+cstr(d)+" days ago]")  
   end if
   ' We add songs until there's a backlog of 5 (startup) 
   ' or until we've reached 20 again 
   Do while (playlist.count<=(playlist.position+13)) 
      Call FindedTrack
   Loop
end if 
 
End Sub 
 
Sub Application_ChangedStatus 
 
if PlayState=0 then 
   ' exit if state has changed to stopped 
   quit 
end if 
 
End Sub
 
examples/sendto/weighted_winamp_party_shuffle.txt · Last modified: 2008/02/24 02:53 by 24.222.217.251
 
Recent changes RSS feed Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Music Plugins