This a script (first try please be gentile ) to rotate the album art. It works ... but I have a problem.
I could not get access to the popup menu of the "Album Art (Now Playing)" so I change the album art of the song and do an update. This gives a small hick up during the play.
So my question, does anybody have an idea if (and how) I can influence the popup menu (so I can select the "next" picture)?
The script (no guarantees jadajadaja ...)
Code: Select all
'-----------------------------OPEN-------------------------------------
Dim FSO : Set FSO=CreateObject("Scripting.FileSystemObject")
Dim SDB : Set SDB=CreateObject("SongsDB.SDBApplication")
While Not SDB.isRunning : WScript.Sleep 500 : Wend
'----------------------------------------------------------------------
Prepare
InstallScriptTo "Auto\RotateArtSetting.vbs" ,066, 140,"none"
InstallScriptTo "RotateArt.vbs" ,142, 217,_
"Script Successfully Installed!" &vbLf&_
"Go to " &vbLf&_
"Tools - Rotate Art" &vbLf&_
"to change the settings."
'------------------------------CLOSE-----------------------------------
SDB.ShutdownAfterDisconnect=True
Set FSO=Nothing : Set SDB=Nothing : Wscript.Quit
'%%%%%%%%%%%%%%%%% START OF SCRIPT INSTALLER %%%%%%%%%%%%%%%%%%
Sub InstallScriptTo(ScriptName, LineBegin, LineEnd, Message)
ScriptName=SDB.ApplicationPath & "Scripts\" & ScriptName
RenameOldScript(ScriptName)
Set TXT=FSO.OpenTextFile(WScript.ScriptFullName,1)
STR=TXT.ReadAll
TXT.Close
LNS=Split(STR,vbNewLine)
Set TXT=FSO.CreateTextFile(ScriptName, True)
For i=LineBegin-1 To LineEnd-1
TXT.WriteLine LNS(i)
Next
TXT.Close
If FSO.FileExists(ScriptName) And Message<>"none" Then _
SDB.MessageBox Message , 2, Array(4)
End Sub
Sub RenameOldScript(ScriptName)
If FSO.FileExists(ScriptName) Then _
FSO.MoveFile ScriptName, BakFile(ScriptName)
End Sub
Function BakFile(ScriptName)
Do
TMP=Left(ScriptName, Len(ScriptName)-3) & "old" & v
v=v+1
Loop While FSO.FileExists(TMP)
BakFile=TMP
End Function
Sub Prepare
RenameOldScript(SDB.ApplicationPath&"Scripts\RotateArt.vbs")
Set INI=SDB.Tools.IniFileByPath(SDB.ApplicationPath&"Scripts\Scripts.ini")
INI.StringValue("RotateArt","FileName")="RotateArt.vbs"
INI.StringValue("RotateArt","ProcName")="RotateArt"
INI.StringValue("RotateArt","Language")="VBScript"
INI.IntValue("RotateArt","ScriptType")=2
End Sub
'%%%%%%%%%%%%%%%%%% END OF SCRIPT INSTALLER %%%%%%%%%%%%%%%%%%%
'-------------------------------------------------------------------------------
' file to create a settings form for RotateArt
' Version 1.0
' date 12 nov 2006.
'-------------------------------------------------------------------------------
Sub OnStartup
MyScript = SDB.ApplicationPath & "scripts\RotateArt.vbs"
' setup menu values on tools
Set UI = SDB.UI
' Add a submenu to the Tools menu...
Set Mnu = UI.AddMenuItem( UI.Menu_Tools, -1, 1)
Mnu.Caption = "Rotate Art"
Mnu.Caption = "Rotate"
Mnu.OnClickFunc = "RotateNow"
Mnu.UseScript=MyScript
Mnu.IconIndex = 25
' and on the now playing popup.
Set Mnu = UI.AddMenuItem( UI.Menu_Pop_NP, -1, 1)
Mnu.Caption = "Rotate"
Mnu.OnClickFunc = "RotateNow"
Mnu.UseScript=MyScript
Mnu.IconIndex = 25
' Create our own option sheet
ind = SDB.UI.AddOptionSheet( "Rotate Art", Script.ScriptPath, "InitSheet", "SaveSheet", 0)
End Sub
Sub InitSheet( Sheet)
' Create a simple sheet with an edit line and a button
Set UI=SDB.UI
' checkbox want it ?
Set CbActive = UI.NewCheckBox(Sheet)
CbActive.Caption="Activate Rotate Art"
Cbactive.Common.ControlName = "cbActive"
Cbactive.Common.SetRect 50, 20, 200, 20
' Create a label on the form
Set Lbl = UI.NewLabel( Sheet)
Lbl.Common.SetRect 50, 40, 200, 20
Lbl.Caption = "Please set a value for the rotate time (in seconds)"
' Create an edit line
Set Edt = UI.NewEdit( Sheet)
Edt.Common.SetRect 50, 60, 30, 20
Edt.Text = "40"
Edt.Common.ControlName = "tbTime"
' Retrieve already entered value from registry
Set Regs = SDB.Registry
If Regs.OpenKey( "Rotate Art", True) Then
If Regs.ValueExists( "RTime") Then
Edt.Text = Regs.StringValue( "RTime") / 1000
End If
If Regs.ValueExists( "Active") Then
CbActive.checked = Regs.StringValue( "Active")
End If
Regs.CloseKey
End If
End Sub
Sub SaveSheet( Sheet)
' Save entered value to registry in order to be able to shown it next time
Set Regs = SDB.Registry
Set Edt = Sheet.Common.ChildControl( "tbTime")
Set CbActive = Sheet.Common.ChildControl( "cbActive")
If IsNumeric(edt.text) Then
If Regs.OpenKey( "Rotate Art", True) Then
Regs.StringValue("RTime") = Edt.Text * 1000
Regs.StringValue( "Active") = CbActive.checked
Regs.CloseKey
End If
Else
SDB.MessageBox "Value '" & edt.text & "' is not a valid number'" , mtInformation, Array(mbOk)
End If
End Sub
'-------------------------------------------------------------------------------
' Script to rotate the album art in mediamonkey
' Version 1.0
' date 12 nov 2006.
'-------------------------------------------------------------------------------
Sub RotateArt
' less than 2 picture, nothing to rotate ...
Set Sng=SDB.Player.CurrentSong
Set art=sng.AlbumArt
If art.count < 2 Then
Exit Sub
End If
' have a setting and want to run?
Set REG=SDB.Registry
If REG.ValueExists( "Active") Then
If REG.StringValue( "Active") Then
Exit Sub ' Not active
End If
End If
If REG.ValueExists( "RTime") Then
Rtime = Regs.StringValue( "RTime")
Else
Rtime = 40000 ' Default is 40 seconds
End If
Script.UnRegisterAllEvents ' Terminate any running timer
' Got enough song, start timer
Set Tmr = SDB.CreateTimer( Rtime ) ' Pop up a message in "Rtime" seconds
Script.RegisterEvent Tmr, "OnTimer", "TestTimer"
End Sub
Sub TestTimer( Timer)
' timer event fired, rotate the picture
Dim MyPic
Dim ThisSong
Dim TmpPic
Set REG=SDB.Registry
If REG.OpenKey("Rotate Art", True) Then
ThisSong = REG.IntValue("CurrSong")
MyPic = REG.IntValue("LastPic")
End If
Set Sng=SDB.Player.CurrentSong
Set art=sng.AlbumArt
' set MyPic to 0 (first pic) when last pic, or new song
If ThisSong <> Sng.ID Then
MyPic = 0
Else
MyPic = MyPic + 1
End If
If MyPic >= art.count Then
MyPic = 0
End If
' restarted, nothing to switch
If MyPic <> 0 Then
' the rotate, change picture 0 with MyPic
Set tmppic = art.item(0)
Set art.item(0) = art.item(MyPic)
Set art.item(MyPic) = tmppic
art.UpdateDB
End If
'Script.UnregisterEvents Timer ' Terminate usage of this timer
' save the current state
ThisSong = Sng.ID
REG.IntValue("CurrSong") = ThisSong
REG.IntValue("LastPic") = MyPic
REG.CloseKey
End Sub
Function RotateNow(Item)
RotateArt
End Function
Sub OnStartup
RotateArt
End Sub