judas wrote:Hey...i checked out the clear now playing script in your page, its a great idea...one small suggestion to add to the next version: why not leave say 10 (or five) files? that way you wouldn't start with an empty now playing...or i dont know if it can be done, but is there a way to know what was the last song in now playing that was played? this way you could remove all songs before that one and you get to keep the ones you didnt get to hear.
Code: Select all
'
' MediaMonkey Script
'
' NAME: ClearNowPlaying 3.1
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 09/07/2012
'
' INSTALL: Copy to Scripts\Auto directory
'
' FIXES: Fixed mode setting not storing correctly
'
Option Explicit
Sub OnStartup
'default settings
Dim ini : Set ini = SDB.IniFile
If ini.StringValue("ClearNowPlaying","Limit") = "" Then
ini.IntValue("ClearNowPlaying","Limit") = 100
End If
If ini.StringValue("ClearNowPlaying","Mode") = "" Then
ini.IntValue("ClearNowPlaying","Mode") = 4
End If
'add option sheet
Call SDB.UI.AddOptionSheet("ClearNowPlaying Settings",Script.ScriptPath,"InitSheet","SaveSheet",-2)
'run script
Dim cur : cur = ini.IntValue("Player","NowPlayingPosition")
Dim lim : lim = ini.IntValue("ClearNowPlaying","Limit")
If SDB.Player.PlaylistCount > lim Then
Select Case ini.IntValue("ClearNowPlaying","Mode")
Case 1
Call SDB.Player.PlaylistClear()
Case 2
Call ClearPlayed(cur,lim)
Case 3
Call ClearExtra(lim)
Case 4
If Not ClearPlayed(cur,lim) Then
Call ClearExtra(lim)
End If
End Select
End If
End Sub
Function ClearPlayed(cur,lim)
Dim i : i = 0
For i = 0 To cur-1
Call SDB.Player.PlaylistDelete(0)
Next
If SDB.Player.PlaylistCount > lim Then
ClearPlayed = False
Else
ClearPlayed = True
End If
End Function
Function ClearExtra(lim)
Dim i : i = 0
For i = lim To SDB.Player.PlaylistCount
Call SDB.Player.PlaylistDelete(lim)
Next
ClearExtra = True
End Function
Sub InitSheet(Sheet)
Dim ini : Set ini = SDB.IniFile
Dim ui : Set ui = SDB.UI
Dim edt : Set edt = ui.NewLabel(Sheet)
edt.Common.SetRect 5, 10, 50, 20
edt.Caption = "Run mode:"
edt.Autosize = False
Set edt = ui.NewDropdown(Sheet)
edt.Common.SetRect 80, 7, 300, 20
edt.Common.ControlName = "CNPMode"
edt.Style = 2
edt.AddItem("Disabled")
edt.AddItem("Clear all tracks")
edt.AddItem("Clear played tracks")
edt.AddItem("Clear tracks leaving 'limit' remaining")
edt.AddItem("Clear played tracks then leave 'limit' remaining")
edt.ItemIndex = ini.IntValue("ClearNowPlaying","Mode")
Set edt = ui.NewLabel(Sheet)
edt.Common.SetRect 5, 35, 50, 20
edt.Caption = "Track limit:"
edt.Autosize = False
Set edt = ui.NewSpinEdit(Sheet)
edt.Common.SetRect 80, 32, 50, 20
edt.Common.ControlName = "CNPLimit"
edt.MinValue = 0
edt.MaxValue = 9999
edt.Value = ini.IntValue("ClearNowPlaying","Limit")
End Sub
Sub SaveSheet(Sheet)
Dim ini : Set ini = SDB.IniFile
ini.IntValue("ClearNowPlaying","Mode") = Sheet.Common.ChildControl("CNPMode").ItemIndex
ini.IntValue("ClearNowPlaying","Limit") = Sheet.Common.ChildControl("CNPLimit").Value
End Sub