Party limit v1.0

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Party limit v1.0

Postby BigMatty » Thu Apr 08, 2010 9:10 am

Hey guys!

When we have house parties I load up mediamonkey with party mode enabled... but there's some problems:

Someone might sit there and queue up multiple songs from their favourite band IN A ROW! Get stuffed!
or
Someone might sit there and queue up 50 songs in a row, not giving anyone else a chance.. bah!

So I wrote this script to detect that, and stop them.


It's very basic, but it does the job. For it to work you need to have 'Automatically retain 0 previous tracks in Now Playing'

Would love for anyone else to improve the script to remove that limit, or enforce it.

Anyway.. please use, modify, share, whatever.. enjoy!

- Matt

Code: Select all

Sub OnStartup

   SDB.IniFile.BoolValue("PartyLimit", "Enabled") = false

   'add toolbar button
   
   Set but = SDB.UI.AddMenuItem(SDB.UI.Menu_TbStandard, 0, 0)
   but.Caption = "Party limit"
   but.IconIndex = 48
   but.UseScript = Script.ScriptPath
   but.OnClickFunc = "ToggleOnOff"
   
   Set SDB.Objects("PartyLimitButton") = but

   Call Script.RegisterEvent(SDB, "OnNowPlayingModified", "CheckNowPlaying")
 
End Sub

Sub ToggleOnOff(arg)

   IsEnabled = SDB.IniFile.BoolValue("PartyLimit", "Enabled")
   Set but = SDB.Objects("PartyLimitButton")
   
   If(IsEnabled) Then
   
      SDB.IniFile.BoolValue("PartyLimit", "Enabled") = false
      but.Checked = false
   
   Else
   
      SDB.IniFile.BoolValue("PartyLimit", "Enabled") = true
      but.Checked = true
   
   End If
   
   Set SDB.Objects("PartyLimitButton") = but

End Sub

Sub CheckNowPlaying

   'Do we run here?
   
   IsEnabled = SDB.IniFile.BoolValue("PartyLimit", "Enabled")
   
   If Not (IsEnabled) Then
   
      Exit Sub
   
   End If
   
   'First step, cull the now playing list if there are too many
   
   Set NowPlayingList = SDB.Player.CurrentSongList
   
   If(NowPlayingList.Count > 10) Then
   
      Call SDB.MessageBox("Too many songs queued up.. grab a beer and come back soon", mtError, Array(mbOk))
   
      For i = 10 to (NowPlayingList.Count - 1)
      
         SDB.Player.PlaylistDelete(i)
      
      Next
   
   End If
   
   
   
   'Now look for duplicate objects and delete them
   
   Set NowPlayingList = SDB.Player.CurrentSongList
   
   Set ArtistsNamesUsed = CreateObject("Scripting.Dictionary")
   
   Set PositionsToRemove = CreateObject("Scripting.Dictionary")
   
   For i = 0 to (NowPlayingList.Count - 1)
   
      Set NowPlayingListSong = NowPlayingList.Item(i)
   
      ArtistName = NowPlayingListSong.Artist.Name
      
      If(ArtistsNamesUsed.Exists( ArtistName )) Then

         PositionsToRemove.Add i, i

      Else
      
         ArtistsNamesUsed.Add ArtistName, ArtistName
         
      End If

   Next

   'Now get removing!
   
   If(PositionsToRemove.Count > 0) Then
   
      Call SDB.MessageBox("1 band = 1 song at a time. Stop spamming, you dick!", mtError, Array(mbOk))
   
   End If
   
   PositionsToRemoveItems = PositionsToRemove.Items
   
   'As we remove things the list index changes on us
   PositionToRemoveIncrement = 0

   For Each PositionToRemove in PositionsToRemoveItems
   
      SDB.Player.PlaylistDelete( PositionToRemove -  PositionToRemoveIncrement)
      
      PositionToRemoveIncrement = PositionToRemoveIncrement + 1

   Next


End Sub

BigMatty
 
Posts: 24
Joined: Tue May 30, 2006 8:14 am

Return to Need Help with Addons?

Who is online

Users browsing this forum: No registered users and 12 guests