MonkeySqueeze Development V3.2
Moderators: Gurus, Addon Administrators
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.1
MonkeySqueeze V.3.0 Released!
Cheers
Gingernut63
Cheers
Gingernut63
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
Re: MonkeySqueeze Development V3.0.1
Gingernut thanks very much for your contribution. I am also developing a Plug-In (in vbs) ( not the same as your MonkeySqueeze but I think it compliments it perfectly, I keep it as a surprise) and I am considering to buy a Logitech Squeezebox only just because your code exists and I want to tweak my own code so it is compatible with yours.
I will contact you in private at some point to tell you about my own work and tune our efforts a bit ......
Again thanks for your contribution of this wonderful idea and plug-in........
Yours
Athanasis
I will contact you in private at some point to tell you about my own work and tune our efforts a bit ......
Again thanks for your contribution of this wonderful idea and plug-in........
Yours
Athanasis
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.1
@Thanasis
You certainly have me intrigued.
regards
Gingernut63
You certainly have me intrigued.
regards
Gingernut63
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
Re: MonkeySqueeze Development V3.0.1
Like said, my program does not do what MonkeySqueeze does, but it complements it. Be patient and you will see !
-
- Posts: 44
- Joined: Fri Jul 30, 2010 8:46 am
Re: MonkeySqueeze Development V3.0.1
@Gingenut63 been a long time and just popped back in to see what's been going on since my "departure". Glad to see you are still progressing things and I'm impressed the 1k barrier and some has long since been breached. In fact 4797 downloads as I type this. Excellent
@Thanasis what has happened since your post on Nov 25th 2011???
@Thanasis what has happened since your post on Nov 25th 2011???
Music & Video Management: Mediamonkey Ver 4.0.0.1436Gold Lifetime
Music Server: Logitech Media Server (LMS) 7.7.0-33512
AddOns: MonkeySqueeze Ver 2.0 http://www.mediamonkey.com/forum/viewto ... =2&t=59515
On Demand Music: LastFM, Spotify via LMS
Music Server: Logitech Media Server (LMS) 7.7.0-33512
AddOns: MonkeySqueeze Ver 2.0 http://www.mediamonkey.com/forum/viewto ... =2&t=59515
On Demand Music: LastFM, Spotify via LMS
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.1
G'day mcstumble, good to see you are still around. Yes it's been steadily running off the shelf with some good feedback. 5000 wasn't on my mind when this process was started, yet surprisingly it's almost there. I have some new ideas for MonkeySqueeze and when work cools down will ramp up development activity again.mccstumble wrote:@Gingenut63 been a long time and just popped back in to see what's been going on since my "departure". Glad to see you are still progressing things and I'm impressed the 1k barrier and some has long since been breached. In fact 4797 downloads as I type this. Excellent
Cheers
Gingernut63
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
-
- Posts: 44
- Joined: Fri Jul 30, 2010 8:46 am
Re: MonkeySqueeze Development V3.0.1
@Gingernut63 Yeah and good you got it so far in such a short time. Less than 200 units until you get to the magical 5k point. That's some doing and I clearly recall as the first few were leaving the shelf and our hope was for 100......how quaint that seems now. Good luck with it all.
I rarely use Mediamonkey but have a fondness and loyaly to it. These days im using Squeezeserver with Spotify and LastFM plugins and haven't ripped a CD in ages. This sadly means I no longer have as much immediate need for Mediamonkey and it's fantastick library maintenance capabilities.
I really wish the Ventis people had looked more closely at the Spotify and LastFM route .....they are even shipping built into some amplifiers and other gadgets these days. That said though i will be keeping Mediamonkey live and using it from time to time for that all important archiving that it is so good at.
Again, good luck with all the Monkeysqueezing
Cheers Mccstumble
I rarely use Mediamonkey but have a fondness and loyaly to it. These days im using Squeezeserver with Spotify and LastFM plugins and haven't ripped a CD in ages. This sadly means I no longer have as much immediate need for Mediamonkey and it's fantastick library maintenance capabilities.
I really wish the Ventis people had looked more closely at the Spotify and LastFM route .....they are even shipping built into some amplifiers and other gadgets these days. That said though i will be keeping Mediamonkey live and using it from time to time for that all important archiving that it is so good at.
Again, good luck with all the Monkeysqueezing
Cheers Mccstumble
Music & Video Management: Mediamonkey Ver 4.0.0.1436Gold Lifetime
Music Server: Logitech Media Server (LMS) 7.7.0-33512
AddOns: MonkeySqueeze Ver 2.0 http://www.mediamonkey.com/forum/viewto ... =2&t=59515
On Demand Music: LastFM, Spotify via LMS
Music Server: Logitech Media Server (LMS) 7.7.0-33512
AddOns: MonkeySqueeze Ver 2.0 http://www.mediamonkey.com/forum/viewto ... =2&t=59515
On Demand Music: LastFM, Spotify via LMS
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.1
Latest Beta release V3.0.1.120314
The current version of the script is optimised for MediaMonkey 4 and above. It will run on MediaMonkey 3 but the options page will not display correctly.
If you haven't used an Alpha or Beta just follow the instructions below, it's easy.
Release improvements:
- Modified options page for connection to Windows Home Server 2011
Known Issues:
N/A
To use this version:
Copy the script to Notepad and save as MonkeySqueeze.vbs to one one of the following locations:
C:\Program Files\MediaMonkey\Scripts\Auto or C:\Program Files (x86)\MediaMonkey\Scripts\Auto
If you use this script please report on this forum if it runs OK or if you had any issues. Feedback is required so we can implement changes before any official release.
The current version of the script is optimised for MediaMonkey 4 and above. It will run on MediaMonkey 3 but the options page will not display correctly.
If you haven't used an Alpha or Beta just follow the instructions below, it's easy.
Release improvements:
- Modified options page for connection to Windows Home Server 2011
Known Issues:
N/A
To use this version:
Copy the script to Notepad and save as MonkeySqueeze.vbs to one one of the following locations:
C:\Program Files\MediaMonkey\Scripts\Auto or C:\Program Files (x86)\MediaMonkey\Scripts\Auto
If you use this script please report on this forum if it runs OK or if you had any issues. Feedback is required so we can implement changes before any official release.
Code: Select all
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
' MonkeySqueeze V3.0.1.120314Beta
'
' UPDATE DATE: 14.03.2012
'
' Script: Development has occurred in two distinct stages: As Squeezebox Controller from 2007 to 2009; and as MonkeySqueeze from 2011 on.
'
' ORIGINAL AUTHOR: Todd Nemeth/revel
' DATE STARTED: 26.09.2007
'
' Squeezebox Controller: Todd Nemeth Mods: Baz, Big_Berny, Peke, trixmoto, debacle, mccstumble
' MonkeySqueeze: Gingernut63, booblers, Katteman
'
' COMMENT:
' - You will also need Logitech Media Server (SqueezeBox Server) installed and running
' - Optional: Install and run SqueezePlay or SoftSqueeze
' - After installation the options page for this script is located at Tools > Options > MonkeySqueeze
'
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Option Explicit
Public EndOfTrack, LMScount, LMSpaths()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim onMonkeySqueezeIcon
Dim offMonkeySqueezeIcon
'**************************************************************
Sub OnStartup
Dim ind, Mnu
Dim UI : Set UI = SDB.UI
onMonkeySqueezeIcon = SDB.RegisterIcon("Scripts\Auto\sbon.ico", 0)
If onMonkeySqueezeIcon < 0 Then
onMonkeySqueezeIcon = 74 'unlocked icon if it doesn't exist
End If
offMonkeySqueezeIcon = SDB.RegisterIcon("Scripts\Auto\sboff.ico", 0)
If offMonkeySqueezeIcon < 0 Then
offMonkeySqueezeIcon = 75 'locked icon if it doesn't exist
End If
Set Mnu = UI.AddMenuItem( UI.Menu_TbStandard, 0, 0)
Mnu.Caption = "MonkeySqueeze"
Mnu.UseScript = Script.ScriptPath
Mnu.OnClickFunc = "SyncToggle"
Mnu.IconIndex = offMonkeySqueezeIcon
Mnu.Hint = "Enable/Disable MonkeySqueeze"
Set SDB.Objects("MonkeySqueezeIcon") = Mnu 'save a reference to it so we can change the icon later.
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False
ind = SDB.UI.AddOptionSheet("MonkeySqueeze",Script.ScriptPath,"InitSheet","SaveSheet",-2)
'logme(slimRequest(formatCommand("""version"",""?""")))
End Sub
'**************************************************************
Sub InitSheet(Sheet)
Dim Panel1, Panel2, Checkbox3, Panel3, Edit1, Panel4, Btn1, Edit2, Panel5, Edit3, Edit4, Edit5, Checkbox1, Checkbox2
Set Panel1 = SDB.UI.NewGroupBox(Sheet)
Panel1.Common.SetRect 10,10,450,50
Panel1.Caption = "MonkeySqueeze v3.0.1"
With SDB.UI.NewLabel(Panel1)
.Common.SetRect 15,22,590,20
.Caption = "This script allows MediaMonkey to play music on a SqueezeBox system"
End With
Set Btn1 = SDB.UI.NewButton(Panel1)
Btn1.Common.SetRect 370,15,65,25
Btn1.Caption = "User Guide"
Btn1.Common.Hint = "Click and then open MonkeySqueeze_UserGuide.pdf"
Script.RegisterEvent Btn1, "OnClick", "UserGuide"
Set Panel2 = SDB.UI.NewGroupBox(Sheet)
Panel2.Common.SetRect 10,70,450,50
Panel2.Caption = "General Settings"
Set CheckBox3 = SDB.UI.NewCheckBox(Panel2)
CheckBox3.Common.SetRect 15,20,150,20
CheckBox3.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle")
CheckBox3.Common.ControlName = "EnablePT"
CheckBox3.Common.Hint = SDB.Localize("When selected if MonkeySqueeze is enabled, the primary SqueezeBox device will power on, and on/off at startup/shutdown. When MonkeySqueeze is disabled, primary SqueezeBox device will power off. Does not work if SqueezePlay is the primary device.")
CheckBox3.Caption = SDB.Localize("Enable Power Toggle")
Set Panel3 = SDB.UI.NewGroupBox(Sheet)
Panel3.Common.SetRect 10,130,450,125
Panel3.Caption = "LMS IP Address and HTTP Port"
With SDB.UI.NewLabel(Panel3)
.Multiline = True
.Common.SetRect 15,20,420,50
.Caption = "Open the LMS (SqueezeBox Server) Web Control page > Settings > Information tab and find the Server IP Address, e.g. 192.168.0.102 and enter below. The default HTTP Port number is 9000. See user guide if you wish to change it."
End With
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 15,74,70,20
.Caption = "IP Address:"
End With
Set Edit1 = SDB.UI.NewEdit(Panel3)
Edit1.Common.ControlName = "SqueezeBoxIP"
Edit1.Common.SetRect 75,70,95,25
Edit1.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP")
If Edit1.Text = "" Then
Edit1.Text = "XXX.XXX.XXX.XXX"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") = "XXX.XXX.XXX.XXX"
End If
Edit1.Common.Hint = "Copy and paste the LMS IP Address here"
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 215,74,70,20
.Caption = "HTTP Port No:"
End With
Set Edit2 = SDB.UI.NewEdit(Panel3)
Edit2.Common.ControlName = "SqueezeBoxPort"
Edit2.Common.SetRect 287,70,40,25
Edit2.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort")
If Edit2.Text = "" Then
Edit2.Text = "9000"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") = "9000"
End If
Edit2.Common.Hint = "HTTP port default is 9000. View the port number in LMS: Web Control page > Settings > Information tab and change if required"
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 15,100,450,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
Set Panel4 = SDB.UI.NewGroupBox(Sheet)
Panel4.Common.SetRect 10,265,450,125
Panel4.Caption = "Primary SqueezeBox Device - MAC Address"
With SDB.UI.NewLabel(Panel4)
.Multiline = True
.Common.SetRect 15,20,420,60
.Caption = "The MAC address of the device (Touch, SqueezePlay, etc...) you wish to connect to. Open the LMS Web Control page > Settings page > Information tab and find the device. Enter the MAC address, e.g. z1:6d:4g:40:1f:32"
End With
With SDB.UI.NewLabel(Panel4)
.Common.SetRect 15,74,70,20
.Caption = "Device MAC Address:"
End With
Set Edit3 = SDB.UI.NewEdit(Panel4)
Edit3.Common.ControlName = "SqueezeBoxMAC"
Edit3.Common.SetRect 122,70,110,25
Edit3.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC")
If Edit3.Text = "" Then
Edit3.Text = "xx:xx:xx:xx:xx:xx"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") = "xx:xx:xx:xx:xx:xx"
End If
Edit3.Common.Hint = "Copy and paste the MAC address here. Use lowercase text for maximum compatibility"
With SDB.UI.NewLabel(Panel4)
.Common.SetRect 15,100,420,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
Set Panel5 = SDB.UI.NewGroupBox(Sheet)
Panel5.Common.SetRect 10,400,450,165
Panel5.Caption = "LMS on a Linux or Windows Server/NAS"
With SDB.UI.NewLabel(Panel5)
.Multiline = True
.Common.SetRect 15,20,420,60
.Caption = "For Linux devices the media folder address in LMS uses forward slashes. e.g. /media/Music. Windows devices use back slashes (\) for all addresses"
End With
Set CheckBox1 = SDB.UI.NewCheckBox(Panel5)
CheckBox1.Common.SetRect 60,53,260,20
CheckBox1.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","NAS")
CheckBox1.Common.ControlName = "EnableNAS"
CheckBox1.Common.Hint = SDB.Localize("Select if using LMS on a Linux or Windows Server/NAS device. See user guide for more details")
CheckBox1.Caption = SDB.Localize("Enable")
Script.RegisterEvent CheckBox1.Common, "OnClick", "NASClick"
Set CheckBox2 = SDB.UI.NewCheckBox(Panel5)
CheckBox2.Common.SetRect 200,53,260,20
CheckBox2.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","Synology")
CheckBox2.Common.ControlName = "EnableSynology"
CheckBox2.Common.Hint = SDB.Localize("Select if using Squeezebox Server prior to v7.5.1. Tested on Synology devices only")
CheckBox2.Caption = SDB.Localize("LMS is prior to v7.5.1 (Linux device only)")
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,84,70,20
.Caption = "MediaMonkey Music Folder:"
End With
Set Edit4 = SDB.UI.NewEdit(Panel5)
Edit4.Common.ControlName = "MediaMonkeyMF"
Edit4.Common.SetRect 148,80,200,25
Edit4.Text = SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF")
If Edit4.Text = "" Then
Edit4.Text = "X:\____\____"
SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF") = "X:\_____\_____"
End If
Edit4.Common.Hint = "Copy from MediaMonkey > File > Add/Rescan Folders or the Path column in the Track Browser section"
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,114,70,20
.Caption = "LMS Media Folder:"
End With
Set Edit5 = SDB.UI.NewEdit(Panel5)
Edit5.Common.ControlName = "SqueezeBoxMF"
Edit5.Common.SetRect 105,110,200,25
Edit5.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF")
If Edit5.Text = "" Then
Edit5.Text = "/___ /___ Linux, or \ ___\ ___ Windows"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF") = "/___ /___ Linux, or \ ___\ ___ Windows"
End If
Edit5.Common.Hint = "Copy and Paste from: LMS Web Page > Settings > Basic Settings tab > Music Folder"
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,140,420,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
CheckBox2.Common.Enabled = CheckBox1.Checked
Edit4.Common.Enabled = CheckBox1.Checked
Edit5.Common.Enabled = CheckBox1.Checked
End Sub
'**************************************************************
Sub NASClick(ChB)
Dim ChB2, Edt4, Edt5
Set ChB2 = ChB.Common.TopParent.Common.ChildControl("EnableSynology")
Set Edt4 = ChB.Common.TopParent.Common.ChildControl("MediaMonkeyMF")
Set Edt5 = ChB.Common.TopParent.Common.ChildControl("SqueezeBoxMF")
ChB2.Common.Enabled = ChB.Checked
Edt4.Common.Enabled = ChB.Checked
Edt5.Common.Enabled = ChB.Checked
End Sub
'**************************************************************
Sub SaveSheet(Sheet)
SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") = Sheet.Common.ChildControl( "EnablePT").Checked
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") = Sheet.Common.ChildControl("SqueezeBoxIP").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") = Sheet.Common.ChildControl("SqueezeBoxPort").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") = Sheet.Common.ChildControl("SqueezeBoxMAC").Text
SDB.IniFile.BoolValue("MonkeySqueeze","NAS") = Sheet.Common.ChildControl( "EnableNAS").Checked
SDB.IniFile.BoolValue("MonkeySqueeze","Synology") = Sheet.Common.ChildControl( "EnableSynology").Checked
SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF") = Sheet.Common.ChildControl("MediaMonkeyMF").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF") = Sheet.Common.ChildControl("SqueezeBoxMF").Text
End Sub
'**************************************************************
Sub UserGuide
On Error Resume Next
Dim OF, FolderToOpen
Set OF = CreateObject("Shell.Application")
FolderToOpen = sdb.ScriptsPath & "Auto\"
OF.Explore FolderToOpen
Set OF = Nothing
End Sub
'**************************************************************
Function SqueezeBoxMode
Dim strRetVal
On Error Resume Next
SqueezeBoxMode = ""
strRetVal = slimRequest(formatCommand("""mode"", ""?"""))
If InStrRev(strRetVal, "play") > 0 Then
SqueezeBoxMode = "play"
ElseIf InStrRev(strRetVal, "stop") > 0 Then
SqueezeBoxMode = "stop"
ElseIf InStrRev(strRetVal, "pause") > 0 Then
SqueezeBoxMode = "pause"
End If
End Function
'**************************************************************
Sub ShowPlayerSettings
Dim Plr, Warning, Res
Warning = ""
Set Plr = SDB.Player
'If Plr.isAutoDJ Then Warning = Warning & vbNewLine & "AutoDJ is on"
If Plr.isCrossFade Then Warning = Warning & vbNewLine & "CrossFade is on"
If Plr.isShuffle Then Warning = Warning & vbNewLine & "Shuffle is on"
If Plr.isEqualizer Then Warning = Warning & vbNewLine & "Equalizer is on"
If Plr.isRepeat Then Warning = Warning & vbNewLine & "Repeat is on"
If Warning <> "" Then
Res = SDB.MessageBox("Selected player settings:" & vbNewLine & _
Warning, mtWarning, Array(mbOk))
End If
End Sub
'**************************************************************
Function SyncToggle( itm )
If SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False Then
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = True
itm.IconIndex = SDB.RegisterIcon("Scripts\Auto\sbon.ico", 0)
Call registerEvents
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""1"""))
ShowPlayerSettings
FillPlaylist
Else
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False
itm.IconIndex = SDB.RegisterIcon("Scripts\Auto\sboff.ico", 0)
Call unregisterEvents
slimRequest(formatCommand("""stop"""))
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""0"""))
End If
End Function
'**************************************************************
Sub Event_OnPlay
Dim strRetVal, Idx
If (SqueezeBoxMode = "play") And EndOfTrack Then
'*** normal playlist continuation
EndOfTrack = False
Else
'*** SqueezeBox is not playing or new track out of order
Idx = SDB.Player.CurrentSongIndex
slimRequest(formatCommand("""playlist"", ""index"", """ + Cstr(Idx) + """"))
End If
End Sub
'**************************************************************
Sub Event_OnTrackEnd
Dim strRetVal, idx, tim, dur
'*** see if current track ended, then playing is not interrupted
EndOfTrack = True
End Sub
'**************************************************************
Function CheckPath(SongValue)
If Left(SongValue.Path,1) = "?" Then
If SongValue.Cached Then
CheckPath = SongValue.CachedPath
Else
CheckPath = SongValue.Path
End If
Else
CheckPath = SongValue.Path
End If
If SDB.IniFile.BoolValue("MonkeySqueeze","NAS") Then
If SDB.IniFile.BoolValue("MonkeySqueeze","Synology") Then CheckPath = Replace(CheckPath,"\","/")
CheckPath = Replace(CheckPath,SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF"),SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF"))
End If
End Function
'**************************************************************
Sub Event_OnStop
slimRequest(formatCommand("""stop"""))
End Sub
'**************************************************************
Sub Event_OnShutdown
On Error Resume Next
slimRequest(formatCommand("""stop"""))
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""0"""))
End Sub
'**************************************************************
Sub Event_OnPause
If SDB.Player.IsPaused Then
slimRequest(formatCommand("""pause"""))
Else
slimRequest(formatCommand("""play"""))
End If
End Sub
'**************************************************************
Sub Event_OnSeek
Dim SBmode, Song, TrackPath, LMStime
SBmode = SqueezeBoxMode
If SBmode = "stop" Then
Set Song = SDB.Player.CurrentSong
TrackPath = CheckPath(Song)
slimRequest(formatCommand("""playlist"", ""play"", """ + perlEscape(TrackPath) + """"))
End If
LMStime = 0.001 * SDB.Player.PlaybackTime
slimRequest(formatCommand("""time"", """ + CStr(LMStime) + """"))
End Sub
'**************************************************************
Function slimRequest(params)
'slimRequest accepts pre-formatted parameter string, returns string of the response'
'logme " >> slimRequest: Begin with " + params
Dim url, prog, objHTTP
Dim cnt : cnt = 0
url = "http://" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") + ":" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") + "/jsonrpc.js"
'Set prog = SDB.Objects("LoadXMLBar")
Set prog = SDB.Progress
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
Call objHTTP.open("POST", url, True)
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.setRequestHeader "X-Requested-With", "XMLHttpRequest"
objHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
objHTTP.send(params)
Do While (objHTTP.readyState < 4) And (cnt < 300)
Call SDB.Tools.Sleep(100)
SDB.ProcessMessages
cnt = cnt+1
If prog.Terminate Then
cnt = 300
End If
Loop
If objHTTP.readyState < 4 Then
Set slimRequest = Nothing
Else
slimRequest = objHTTP.responseText
End If
End Function
'*************************************************************
'This is is a JSON RPC call - We're directly calling functions in the Slim::Request module in Perl. See here:
'http://svn.slimdevices.com/repos/slim/7.5/trunk/server/Slim/Control/Request.pm
'the addDispatch section tells you how to use the commands and what the RPC module is looking for in terms of formatting
Function formatCommand(str1)
formatCommand = "{""id"":1,""method"":""slim.request"",""params"":[""" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") + """,[" + str1 + "]]}"
End Function
'*************************************************************
'borrowed from a teknojunky - if you want the popups add them to this and then just call logme
Sub logme(msg)
Dim fso, logf
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set logf = fso.OpenTextFile(Script.ScriptPath&".log",ForAppending,True)
logf.WriteLine Now() & ": " & msg
Set fso = Nothing
Set logf = Nothing
End Sub
'*************************************************************
'Perl is taking the JSON strings directly into variables - "\" is a special character in perl to escape the following string
'wherever we have a "\" we need it to be "\\" in anything that goes to Perl (ie: anything that goes to SqueezeBox)
Function perlEscape(str1)
perlEscape = Replace(str1, "\", "\\")
End Function
'*************************************************************
Sub registerEvents
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnSeek","Event_OnSeek")
Call Script.RegisterEvent(SDB,"OnTrackEnd","Event_OnTrackEnd")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnNowPlayingModified","Event_OnNowPlayingModified")
End Sub
'*************************************************************
Sub Event_OnNowPlayingModified
Dim MMcount
MMcount = SDB.Player.CurrentPlayList.Count
'logme("Now playing modified")
'logme("Aantal MM tracks: " & Cstr(MMcount))
'logme("Aantal LMS tracks: " & Cstr(LMScount))
If SqueezeBoxMode = "stop" Then
FillPlaylist
ElseIf MMcount = 0 Then
ResetPlaylist
ElseIf MMcount < LMScount Then
TracksDeleted(MMcount)
ElseIf MMcount > LMScount Then
TracksAdded(MMcount)
Else
TracksMoved
End If
End Sub
'*************************************************************
Sub FillPlaylist
'*** synchronize MM playlist with LMS playlist
Dim tempStop, Idx
'*** clear LMS playlist and stop shuffle!!
slimRequest(formatCommand("""playlist"", ""clear"""))
slimRequest(formatCommand("""playlist"", ""shuffle"", ""0"""))
'*** copy MM playlist - if any - to LMS
LMScount = SDB.Player.CurrentPlayList.Count
ReDim LMSpaths(LMScount)
'*** if playlist is empty we are done
If LMScount > 0 Then
tempStop = SDB.Player.isPlaying And (SDB.Player.PlayBackTime < 2000)
If tempStop Then
SDB.Player.pause
slimRequest(formatCommand("""stop"""))
End If
SendPlaylist
'*** jump to current song
Idx = SDB.Player.CurrentSongIndex
slimRequest(formatCommand("""playlist"", ""index"", """ + Cstr(Idx) + """"))
If tempStop Then
'*** Start playback after filling playlist
SDB.Player.Pause
ElseIf SDB.Player.isPlaying Then
'*** Synchronize LMS with current track
slimRequest(formatCommand("""time"", """ + CStr(SDB.Player.PlaybackTime*0.001) + """"))
If SDB.Player.isPaused Then SDB.Player.Pause
Else
'*** MediaMonkey is not playing
slimRequest(formatCommand("""stop"""))
End If
End If
EndOfTrack = False
End Sub
'**************************************************************
Sub SendPlaylist
Dim Progr, TrackPath, Song, n
'*** show progress bar
Set Progr = SDB.Progress
Progr.Text = SDB.Localize("Synchronising playlists...")
Progr.MaxValue = LMScount
'*** send playlist
For n=0 To LMScount-1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
LMSpaths(n) = TrackPath
slimRequest(formatCommand("""playlist"", ""add"", """ + perlEscape(TrackPath) + """"))
Progr.Value = n+1
Next
End Sub
'**************************************************************
Sub ResetPlaylist
SDB.Player.Stop
slimRequest(formatCommand("""stop"""))
slimRequest(formatCommand("""playlist"", ""clear"""))
ReDim LMSpaths(0)
LMScount = 0
End Sub
'**************************************************************
Sub TracksDeleted(MMcount)
Dim n, m, Song, TrackPath
'logme("Tracks deleted")
n = 0
Do While MMcount < LMScount
If n = MMcount Then
TrackPath = "***"
Else
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
End If
If (TrackPath = LMSpaths(n)) Then
n = n+1
Else
LMScount = LMScount - 1
For m = n To LMScount - 1
LMSpaths(m) = LMSpaths(m+1)
Next
slimRequest(formatCommand("""playlist"", ""delete"", """ + Cstr(n) + """"))
End If
Loop
End Sub
'*************************************************************
Sub TracksAdded(MMcount)
Dim n, m, Song, TrackPath
'logme("Tracks added")
ReDim Preserve LMSpaths(MMcount) 'expand array, preserve content
Do
For n = 0 to MMcount -1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
If (TrackPath <> LMSpaths(n)) Then
slimRequest(formatCommand("""playlist"", ""add"", """ + perlEscape(TrackPath) + """"))
If n < LMScount Then
slimRequest(formatCommand("""playlist"", ""move"", """ + Cstr(LMScount) + """, """ + Cstr(n) + """"))
For m = LMScount To n+1 Step -1
LMSpaths(m) = LMSpaths(m-1)
Next
End If
LMSpaths(n) = TrackPath
LMScount = LMScount + 1
End If
Next
Loop While MMcount > LMScount
End Sub
'*************************************************************
Sub TracksMoved
Dim n, m, i, Song, TrackPath, tempPath
'logme("Tracks moved")
For n=0 To LMScount-1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
If TrackPath <> LMSpaths(n) Then
For m=n+1 To LMScount-1
If TrackPath = LMSpaths(m) Then Exit For
Next
For i=m To n+1 Step -1
LMSpaths(i) = LMSpaths(i-1)
Next
LMSpaths(n) = TrackPath
slimRequest(formatCommand("""playlist"", ""move"", """ + Cstr(m) + """, """ + Cstr(n) + """"))
End If
Next
End Sub
'*************************************************************
Sub unregisterEvents
Script.UnregisterEvents SDB
End Sub
'*************************************************************
'These are what the full JSON strings look like that need to be sent to slimRequest()
'formatRequest() fills in the first part and all you have to do is pick the RPC commands from http://svn.slimdevices.com/repos/slim/7.5/trunk/server/Slim/Control/Request.pm
'Note: there are cleaner ways of doing this - but this is quick and dirty. It just means that you have to use a lot of """ and etc in vbscript.
'This entire script is much easier to write in jscript but I don't know jscript at all so, shrug.
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["status","-",1,"tags:cgABbehldiqtyrSuoKLN"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["status","-",1,"tags:uB"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["playlist","index",28]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["pause"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",[""playlist"", ""play"", ""D:\\MP3\\filename.mp3""]]}
'You can do ANYTHING you can do from the web interface via this RPC engine because you are directly calling the methods in Perl
'so you could add whole playlists and etc see the docs. Sky's the limit.
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.1
MonkeySqueeze V.3.0.1 Released!
Cheers
Gingernut63
Cheers
Gingernut63
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
Re: MonkeySqueeze Development V3.0.2 & above
Hi Gingernut,
First of all, THX for your script. Love it.
My problem is that When the LastFM addon auto adds tracks to MediaMonkey, they are not loaded in Squeezebox.
Can this be fixed?
First of all, THX for your script. Love it.
My problem is that When the LastFM addon auto adds tracks to MediaMonkey, they are not loaded in Squeezebox.
Can this be fixed?
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.2 & above
Thanks for the feedback, much appreciated.pjzzz wrote:Hi Gingernut,
First of all, THX for your script. Love it.
My problem is that When the LastFM addon auto adds tracks to MediaMonkey, they are not loaded in Squeezebox.
Can this be fixed?
The short answer to your question is no. MediaMonkey and Squeezebox must have access to the same music track, hence they both access the same database. MonkeySqueeze sends the address of the track playing in MediaMonkey to Squeezebox so it can find it and play it as well. As the LastFM addon is only accessible to MediaMonkey, Squeezebox cannot access the music track.
You can however use the Squeezebox LastFM Radio plugin to play music and then use SqueezePlay to listen to the music on your PC as well as other Squeezebox devices. Hope this is helpful.
Cheers
Gingernut63
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.2.
Latest Beta release V3.0.2.120627
The current version of the script is optimised for MediaMonkey 4 and above. It will run on MediaMonkey 3 but the options page will not display correctly.
If you haven't used a Beta just follow the instructions below, it's easy. Try a Beta, they're safe and you'll be helping with the development.
Release improvements:
- Made changes to the code for using the Hostname of the server or the IP Address. Very useful if LMS runs on another computer or network server and the IP Address is not static or constantly changes after a reboot or restart.
Has been tested on WHS 2012 by myself but not on a Linux server/NAS. (problems encountered - see below)
Known Issues:
When MonkeySqueeze is enabled there is a initial delay of a few seconds before connection with LMS is made.
UPDATE 10July - Resolving the Hostname: There are excessive delays when resolving the Hostname on my system which is causing the delay mentioned previously. The issue appears to be related to a dual stack or hybrid IP network setup running IPv4 and IPv6. The Hostname is trying to resolve to IPv6 first which is causing a delay of approximately 25 seconds, after this point it resolves to IPv4 and all is ok. This process will occur again when MonkeySqueeze needs to send updated playlist info to LMS. Temporary fix: Deselect IPv6 support on the PC NIC. Communications are now instantaneous. Investigating further.
To use this version:
Copy the script to Notepad and save as MonkeySqueeze.vbs to one one of the following locations:
C:\Program Files\MediaMonkey\Scripts\Auto or C:\Program Files (x86)\MediaMonkey\Scripts\Auto
If you use this script please report on this forum if it runs OK or if you had any issues. Feedback is appreciated so we can implement changes before any official release.
The current version of the script is optimised for MediaMonkey 4 and above. It will run on MediaMonkey 3 but the options page will not display correctly.
If you haven't used a Beta just follow the instructions below, it's easy. Try a Beta, they're safe and you'll be helping with the development.
Release improvements:
- Made changes to the code for using the Hostname of the server or the IP Address. Very useful if LMS runs on another computer or network server and the IP Address is not static or constantly changes after a reboot or restart.
Has been tested on WHS 2012 by myself but not on a Linux server/NAS. (problems encountered - see below)
Known Issues:
When MonkeySqueeze is enabled there is a initial delay of a few seconds before connection with LMS is made.
UPDATE 10July - Resolving the Hostname: There are excessive delays when resolving the Hostname on my system which is causing the delay mentioned previously. The issue appears to be related to a dual stack or hybrid IP network setup running IPv4 and IPv6. The Hostname is trying to resolve to IPv6 first which is causing a delay of approximately 25 seconds, after this point it resolves to IPv4 and all is ok. This process will occur again when MonkeySqueeze needs to send updated playlist info to LMS. Temporary fix: Deselect IPv6 support on the PC NIC. Communications are now instantaneous. Investigating further.
To use this version:
Copy the script to Notepad and save as MonkeySqueeze.vbs to one one of the following locations:
C:\Program Files\MediaMonkey\Scripts\Auto or C:\Program Files (x86)\MediaMonkey\Scripts\Auto
If you use this script please report on this forum if it runs OK or if you had any issues. Feedback is appreciated so we can implement changes before any official release.
Code: Select all
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
' MonkeySqueeze V3.0.2.120627 BETA
'
' UPDATE DATE: 27.06.2012
'
' Script: Development has occurred in two distinct stages: As Squeezebox Controller from 2007 to 2009; and as MonkeySqueeze from 2011 on.
'
' ORIGINAL AUTHOR: Todd Nemeth/revel
' DATE STARTED: 26.09.2007
'
' Squeezebox Controller: Todd Nemeth Mods: Baz, Big_Berny, Peke, trixmoto, debacle, mccstumble
' MonkeySqueeze: Gingernut63, booblers, Katteman
'
' COMMENT:
' - You will also need Logitech Media Server installed and running
' - Optional: Install and run SqueezePlay or SoftSqueeze
' - After installation the options page for this script is located at Tools > Options > MonkeySqueeze
'
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Option Explicit
Public EndOfTrack, LMScount, LMSpaths()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim onMonkeySqueezeIcon
Dim offMonkeySqueezeIcon
'**************************************************************
Sub OnStartup
Dim ind, Mnu
Dim UI : Set UI = SDB.UI
onMonkeySqueezeIcon = SDB.RegisterIcon("Scripts\Auto\sbon.ico", 0)
If onMonkeySqueezeIcon < 0 Then
onMonkeySqueezeIcon = 74 'unlocked icon if it doesn't exist
End If
offMonkeySqueezeIcon = SDB.RegisterIcon("Scripts\Auto\sboff.ico", 0)
If offMonkeySqueezeIcon < 0 Then
offMonkeySqueezeIcon = 75 'locked icon if it doesn't exist
End If
Set Mnu = UI.AddMenuItem( UI.Menu_TbStandard, 0, 0)
Mnu.Caption = "MonkeySqueeze"
Mnu.UseScript = Script.ScriptPath
Mnu.OnClickFunc = "SyncToggle"
Mnu.IconIndex = offMonkeySqueezeIcon
Mnu.Hint = "Enable/Disable MonkeySqueeze"
Set SDB.Objects("MonkeySqueezeIcon") = Mnu 'save a reference to it so we can change the icon later.
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False
ind = SDB.UI.AddOptionSheet("MonkeySqueeze",Script.ScriptPath,"InitSheet","SaveSheet",-2)
'logme(slimRequest(formatCommand("""version"",""?""")))
End Sub
'**************************************************************
Sub InitSheet(Sheet)
Dim Panel1, Panel2, Checkbox3, Panel3, Edit1, Panel4, Btn1, Edit2, Panel5, Edit3, Edit4, Edit5, Checkbox1, Checkbox2
Set Panel1 = SDB.UI.NewGroupBox(Sheet)
Panel1.Common.SetRect 10,10,450,50
Panel1.Caption = "MonkeySqueeze v3.0.1"
With SDB.UI.NewLabel(Panel1)
.Common.SetRect 15,22,590,20
.Caption = "This script allows MediaMonkey to play music on a SqueezeBox system"
End With
Set Btn1 = SDB.UI.NewButton(Panel1)
Btn1.Common.SetRect 370,15,65,25
Btn1.Caption = "User Guide"
Btn1.Common.Hint = "Click and then open MonkeySqueeze_UserGuide.pdf"
Script.RegisterEvent Btn1, "OnClick", "UserGuide"
Set Panel2 = SDB.UI.NewGroupBox(Sheet)
Panel2.Common.SetRect 10,70,450,50
Panel2.Caption = "General Settings"
Set CheckBox3 = SDB.UI.NewCheckBox(Panel2)
CheckBox3.Common.SetRect 15,20,150,20
CheckBox3.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle")
CheckBox3.Common.ControlName = "EnablePT"
CheckBox3.Common.Hint = SDB.Localize("When selected if MonkeySqueeze is enabled, the primary SqueezeBox device will power on, and on/off at startup/shutdown. When MonkeySqueeze is disabled, primary SqueezeBox device will power off. Does not work if SqueezePlay is the primary device.")
CheckBox3.Caption = SDB.Localize("Enable Power Toggle")
Set Panel3 = SDB.UI.NewGroupBox(Sheet)
Panel3.Common.SetRect 10,130,450,125
Panel3.Caption = "LMS IP Address/Hostname and HTTP Port"
With SDB.UI.NewLabel(Panel3)
.Multiline = True
.Common.SetRect 15,20,420,50
.Caption = "Open the LMS Web Control page > Settings > Information tab and find the Server IP Address, e.g. 192.168.0.102 or the Hostname. The default HTTP Port number is 9000. See user guide if you wish to change it."
End With
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 15,74,70,20
.Caption = "IP Address or Hostname:"
End With
Set Edit1 = SDB.UI.NewEdit(Panel3)
Edit1.Common.ControlName = "SqueezeBoxIP"
Edit1.Common.SetRect 139,70,95,25
Edit1.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP")
If Edit1.Text = "" Then
Edit1.Text = "XXX.XXX.XXX.XXX"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") = "XXX.XXX.XXX.XXX"
End If
Edit1.Common.Hint = "Use the LMS IP Address if it is a static address and/or it doesn't change, or use the Hostname (computer name) if the Network Router regularly changes the IP Address"
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 260,74,70,20
.Caption = "HTTP Port No:"
End With
Set Edit2 = SDB.UI.NewEdit(Panel3)
Edit2.Common.ControlName = "SqueezeBoxPort"
Edit2.Common.SetRect 332,70,40,25
Edit2.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort")
If Edit2.Text = "" Then
Edit2.Text = "9000"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") = "9000"
End If
Edit2.Common.Hint = "HTTP port default is 9000. View the port number in LMS: Web Control page > Settings > Information tab and change if required"
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 15,100,450,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
Set Panel4 = SDB.UI.NewGroupBox(Sheet)
Panel4.Common.SetRect 10,265,450,125
Panel4.Caption = "Primary SqueezeBox Device - MAC Address"
With SDB.UI.NewLabel(Panel4)
.Multiline = True
.Common.SetRect 15,20,420,60
.Caption = "The MAC address of the device (Touch, SqueezePlay, etc...) you wish to connect to. Open the LMS Web Control page > Settings page > Information tab and find the device. Enter the MAC address, e.g. z1:6d:4g:40:1f:32"
End With
With SDB.UI.NewLabel(Panel4)
.Common.SetRect 15,74,70,20
.Caption = "Device MAC Address:"
End With
Set Edit3 = SDB.UI.NewEdit(Panel4)
Edit3.Common.ControlName = "SqueezeBoxMAC"
Edit3.Common.SetRect 122,70,110,25
Edit3.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC")
If Edit3.Text = "" Then
Edit3.Text = "xx:xx:xx:xx:xx:xx"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") = "xx:xx:xx:xx:xx:xx"
End If
Edit3.Common.Hint = "Copy and paste the MAC address here. Use lowercase text for maximum compatibility"
With SDB.UI.NewLabel(Panel4)
.Common.SetRect 15,100,420,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
Set Panel5 = SDB.UI.NewGroupBox(Sheet)
Panel5.Common.SetRect 10,400,450,165
Panel5.Caption = "LMS on a Linux or Windows Server/NAS"
With SDB.UI.NewLabel(Panel5)
.Multiline = True
.Common.SetRect 15,20,420,60
.Caption = "For Linux devices the media folder address in LMS uses forward slashes. e.g. /media/Music. Windows devices use back slashes (\) for all addresses"
End With
Set CheckBox1 = SDB.UI.NewCheckBox(Panel5)
CheckBox1.Common.SetRect 60,53,260,20
CheckBox1.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","NAS")
CheckBox1.Common.ControlName = "EnableNAS"
CheckBox1.Common.Hint = SDB.Localize("Select if using LMS on a Linux or Windows Server/NAS device. See user guide for more details")
CheckBox1.Caption = SDB.Localize("Enable")
Script.RegisterEvent CheckBox1.Common, "OnClick", "NASClick"
Set CheckBox2 = SDB.UI.NewCheckBox(Panel5)
CheckBox2.Common.SetRect 200,53,260,20
CheckBox2.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","Synology")
CheckBox2.Common.ControlName = "EnableSynology"
CheckBox2.Common.Hint = SDB.Localize("Select if using Squeezebox Server prior to v7.5.1. Tested on Synology devices only")
CheckBox2.Caption = SDB.Localize("LMS is prior to v7.5.1 (Linux device only)")
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,84,70,20
.Caption = "MediaMonkey Music Folder:"
End With
Set Edit4 = SDB.UI.NewEdit(Panel5)
Edit4.Common.ControlName = "MediaMonkeyMF"
Edit4.Common.SetRect 148,80,200,25
Edit4.Text = SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF")
If Edit4.Text = "" Then
Edit4.Text = "X:\____\____"
SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF") = "X:\_____\_____"
End If
Edit4.Common.Hint = "Copy from MediaMonkey > File > Add/Rescan Folders or the Path column in the Track Browser section"
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,114,70,20
.Caption = "LMS Media Folder:"
End With
Set Edit5 = SDB.UI.NewEdit(Panel5)
Edit5.Common.ControlName = "SqueezeBoxMF"
Edit5.Common.SetRect 105,110,200,25
Edit5.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF")
If Edit5.Text = "" Then
Edit5.Text = "/___ /___ Linux, or \ ___\ ___ Windows"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF") = "/___ /___ Linux, or \ ___\ ___ Windows"
End If
Edit5.Common.Hint = "Copy and Paste from: LMS Web Page > Settings > Basic Settings tab > Music Folder"
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,140,420,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
CheckBox2.Common.Enabled = CheckBox1.Checked
Edit4.Common.Enabled = CheckBox1.Checked
Edit5.Common.Enabled = CheckBox1.Checked
End Sub
'**************************************************************
Sub NASClick(ChB)
Dim ChB2, Edt4, Edt5
Set ChB2 = ChB.Common.TopParent.Common.ChildControl("EnableSynology")
Set Edt4 = ChB.Common.TopParent.Common.ChildControl("MediaMonkeyMF")
Set Edt5 = ChB.Common.TopParent.Common.ChildControl("SqueezeBoxMF")
ChB2.Common.Enabled = ChB.Checked
Edt4.Common.Enabled = ChB.Checked
Edt5.Common.Enabled = ChB.Checked
End Sub
'**************************************************************
Sub SaveSheet(Sheet)
SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") = Sheet.Common.ChildControl( "EnablePT").Checked
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") = Sheet.Common.ChildControl("SqueezeBoxIP").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") = Sheet.Common.ChildControl("SqueezeBoxPort").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") = Sheet.Common.ChildControl("SqueezeBoxMAC").Text
SDB.IniFile.BoolValue("MonkeySqueeze","NAS") = Sheet.Common.ChildControl( "EnableNAS").Checked
SDB.IniFile.BoolValue("MonkeySqueeze","Synology") = Sheet.Common.ChildControl( "EnableSynology").Checked
SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF") = Sheet.Common.ChildControl("MediaMonkeyMF").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF") = Sheet.Common.ChildControl("SqueezeBoxMF").Text
End Sub
'**************************************************************
Sub UserGuide
On Error Resume Next
Dim OF, FolderToOpen
Set OF = CreateObject("Shell.Application")
FolderToOpen = sdb.ScriptsPath & "Auto\"
OF.Explore FolderToOpen
Set OF = Nothing
End Sub
'**************************************************************
Function SqueezeBoxMode
Dim strRetVal
On Error Resume Next
SqueezeBoxMode = ""
strRetVal = slimRequest(formatCommand("""mode"", ""?"""))
If InStrRev(strRetVal, "play") > 0 Then
SqueezeBoxMode = "play"
ElseIf InStrRev(strRetVal, "stop") > 0 Then
SqueezeBoxMode = "stop"
ElseIf InStrRev(strRetVal, "pause") > 0 Then
SqueezeBoxMode = "pause"
End If
End Function
'**************************************************************
Sub ShowPlayerSettings
Dim Plr, Warning, Res
Warning = ""
Set Plr = SDB.Player
'If Plr.isAutoDJ Then Warning = Warning & vbNewLine & "AutoDJ is on"
If Plr.isCrossFade Then Warning = Warning & vbNewLine & "CrossFade is on"
If Plr.isShuffle Then Warning = Warning & vbNewLine & "Shuffle is on"
If Plr.isEqualizer Then Warning = Warning & vbNewLine & "Equalizer is on"
If Plr.isRepeat Then Warning = Warning & vbNewLine & "Repeat is on"
If Warning <> "" Then
Res = SDB.MessageBox("Selected player settings:" & vbNewLine & _
Warning, mtWarning, Array(mbOk))
End If
End Sub
'**************************************************************
Function SyncToggle( itm )
If SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False Then
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = True
itm.IconIndex = SDB.RegisterIcon("Scripts\Auto\sbon.ico", 0)
Call registerEvents
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""1"""))
ShowPlayerSettings
FillPlaylist
Else
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False
itm.IconIndex = SDB.RegisterIcon("Scripts\Auto\sboff.ico", 0)
Call unregisterEvents
slimRequest(formatCommand("""stop"""))
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""0"""))
End If
End Function
'**************************************************************
Sub Event_OnPlay
Dim strRetVal, Idx
If (SqueezeBoxMode = "play") And EndOfTrack Then
'*** normal playlist continuation
EndOfTrack = False
Else
'*** SqueezeBox is not playing or new track out of order
Idx = SDB.Player.CurrentSongIndex
slimRequest(formatCommand("""playlist"", ""index"", """ + Cstr(Idx) + """"))
End If
End Sub
'**************************************************************
Sub Event_OnTrackEnd
Dim strRetVal, idx, tim, dur
'*** see if current track ended, then playing is not interrupted
EndOfTrack = True
End Sub
'**************************************************************
Function CheckPath(SongValue)
If Left(SongValue.Path,1) = "?" Then
If SongValue.Cached Then
CheckPath = SongValue.CachedPath
Else
CheckPath = SongValue.Path
End If
Else
CheckPath = SongValue.Path
End If
If SDB.IniFile.BoolValue("MonkeySqueeze","NAS") Then
If SDB.IniFile.BoolValue("MonkeySqueeze","Synology") Then CheckPath = Replace(CheckPath,"\","/")
CheckPath = Replace(CheckPath,SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF"),SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF"))
End If
End Function
'**************************************************************
Sub Event_OnStop
slimRequest(formatCommand("""stop"""))
End Sub
'**************************************************************
Sub Event_OnShutdown
On Error Resume Next
slimRequest(formatCommand("""stop"""))
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""0"""))
End Sub
'**************************************************************
Sub Event_OnPause
If SDB.Player.IsPaused Then
slimRequest(formatCommand("""pause"""))
Else
slimRequest(formatCommand("""play"""))
End If
End Sub
'**************************************************************
Sub Event_OnSeek
Dim SBmode, Song, TrackPath, LMStime
SBmode = SqueezeBoxMode
If SBmode = "stop" Then
Set Song = SDB.Player.CurrentSong
TrackPath = CheckPath(Song)
slimRequest(formatCommand("""playlist"", ""play"", """ + perlEscape(TrackPath) + """"))
End If
LMStime = 0.001 * SDB.Player.PlaybackTime
slimRequest(formatCommand("""time"", """ + CStr(LMStime) + """"))
End Sub
'**************************************************************
Function slimRequest(params)
'slimRequest accepts pre-formatted parameter string, returns string of the response'
'logme " >> slimRequest: Begin with " + params
Dim url, prog, objHTTP
Dim cnt : cnt = 0
url = "http://" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") + ":" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") + "/jsonrpc.js"
'Set prog = SDB.Objects("LoadXMLBar")
Set prog = SDB.Progress
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
Call objHTTP.open("POST", url, True)
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.setRequestHeader "X-Requested-With", "XMLHttpRequest"
objHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
objHTTP.send(params)
Do While (objHTTP.readyState < 4) And (cnt < 300)
Call SDB.Tools.Sleep(100)
SDB.ProcessMessages
cnt = cnt+1
If prog.Terminate Then
cnt = 300
End If
Loop
If objHTTP.readyState < 4 Then
Set slimRequest = Nothing
Else
slimRequest = objHTTP.responseText
End If
End Function
'*************************************************************
'This is is a JSON RPC call - We're directly calling functions in the Slim::Request module in Perl. See here:
'http://svn.slimdevices.com/repos/slim/7.5/trunk/server/Slim/Control/Request.pm
'the addDispatch section tells you how to use the commands and what the RPC module is looking for in terms of formatting
Function formatCommand(str1)
formatCommand = "{""id"":1,""method"":""slim.request"",""params"":[""" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") + """,[" + str1 + "]]}"
End Function
'*************************************************************
'borrowed from a teknojunky - if you want the popups add them to this and then just call logme
Sub logme(msg)
Dim fso, logf
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set logf = fso.OpenTextFile(Script.ScriptPath&".log",ForAppending,True)
logf.WriteLine Now() & ": " & msg
Set fso = Nothing
Set logf = Nothing
End Sub
'*************************************************************
'Perl is taking the JSON strings directly into variables - "\" is a special character in perl to escape the following string
'wherever we have a "\" we need it to be "\\" in anything that goes to Perl (ie: anything that goes to SqueezeBox)
Function perlEscape(str1)
perlEscape = Replace(str1, "\", "\\")
End Function
'*************************************************************
Sub registerEvents
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnSeek","Event_OnSeek")
Call Script.RegisterEvent(SDB,"OnTrackEnd","Event_OnTrackEnd")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnNowPlayingModified","Event_OnNowPlayingModified")
End Sub
'*************************************************************
Sub Event_OnNowPlayingModified
Dim MMcount
MMcount = SDB.Player.CurrentPlayList.Count
'logme("Now playing modified")
'logme("Aantal MM tracks: " & Cstr(MMcount))
'logme("Aantal LMS tracks: " & Cstr(LMScount))
If SqueezeBoxMode = "stop" Then
FillPlaylist
ElseIf MMcount = 0 Then
ResetPlaylist
ElseIf MMcount < LMScount Then
TracksDeleted(MMcount)
ElseIf MMcount > LMScount Then
TracksAdded(MMcount)
Else
TracksMoved
End If
End Sub
'*************************************************************
Sub FillPlaylist
'*** synchronize MM playlist with LMS playlist
Dim tempStop, Idx
'*** clear LMS playlist and stop shuffle!!
slimRequest(formatCommand("""playlist"", ""clear"""))
slimRequest(formatCommand("""playlist"", ""shuffle"", ""0"""))
'*** copy MM playlist - if any - to LMS
LMScount = SDB.Player.CurrentPlayList.Count
ReDim LMSpaths(LMScount)
'*** if playlist is empty we are done
If LMScount > 0 Then
tempStop = SDB.Player.isPlaying And (SDB.Player.PlayBackTime < 2000)
If tempStop Then
SDB.Player.pause
slimRequest(formatCommand("""stop"""))
End If
SendPlaylist
'*** jump to current song
Idx = SDB.Player.CurrentSongIndex
slimRequest(formatCommand("""playlist"", ""index"", """ + Cstr(Idx) + """"))
If tempStop Then
'*** Start playback after filling playlist
SDB.Player.Pause
ElseIf SDB.Player.isPlaying Then
'*** Synchronize LMS with current track
slimRequest(formatCommand("""time"", """ + CStr(SDB.Player.PlaybackTime*0.001) + """"))
If SDB.Player.isPaused Then SDB.Player.Pause
Else
'*** MediaMonkey is not playing
slimRequest(formatCommand("""stop"""))
End If
End If
EndOfTrack = False
End Sub
'**************************************************************
Sub SendPlaylist
Dim Progr, TrackPath, Song, n
'*** show progress bar
Set Progr = SDB.Progress
Progr.Text = SDB.Localize("Synchronising playlists...")
Progr.MaxValue = LMScount
'*** send playlist
For n=0 To LMScount-1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
LMSpaths(n) = TrackPath
slimRequest(formatCommand("""playlist"", ""add"", """ + perlEscape(TrackPath) + """"))
Progr.Value = n+1
Next
End Sub
'**************************************************************
Sub ResetPlaylist
SDB.Player.Stop
slimRequest(formatCommand("""stop"""))
slimRequest(formatCommand("""playlist"", ""clear"""))
ReDim LMSpaths(0)
LMScount = 0
End Sub
'**************************************************************
Sub TracksDeleted(MMcount)
Dim n, m, Song, TrackPath
'logme("Tracks deleted")
n = 0
Do While MMcount < LMScount
If n = MMcount Then
TrackPath = "***"
Else
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
End If
If (TrackPath = LMSpaths(n)) Then
n = n+1
Else
LMScount = LMScount - 1
For m = n To LMScount - 1
LMSpaths(m) = LMSpaths(m+1)
Next
slimRequest(formatCommand("""playlist"", ""delete"", """ + Cstr(n) + """"))
End If
Loop
End Sub
'*************************************************************
Sub TracksAdded(MMcount)
Dim n, m, Song, TrackPath
'logme("Tracks added")
ReDim Preserve LMSpaths(MMcount) 'expand array, preserve content
Do
For n = 0 to MMcount -1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
If (TrackPath <> LMSpaths(n)) Then
slimRequest(formatCommand("""playlist"", ""add"", """ + perlEscape(TrackPath) + """"))
If n < LMScount Then
slimRequest(formatCommand("""playlist"", ""move"", """ + Cstr(LMScount) + """, """ + Cstr(n) + """"))
For m = LMScount To n+1 Step -1
LMSpaths(m) = LMSpaths(m-1)
Next
End If
LMSpaths(n) = TrackPath
LMScount = LMScount + 1
End If
Next
Loop While MMcount > LMScount
End Sub
'*************************************************************
Sub TracksMoved
Dim n, m, i, Song, TrackPath, tempPath
'logme("Tracks moved")
For n=0 To LMScount-1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
If TrackPath <> LMSpaths(n) Then
For m=n+1 To LMScount-1
If TrackPath = LMSpaths(m) Then Exit For
Next
For i=m To n+1 Step -1
LMSpaths(i) = LMSpaths(i-1)
Next
LMSpaths(n) = TrackPath
slimRequest(formatCommand("""playlist"", ""move"", """ + Cstr(m) + """, """ + Cstr(n) + """"))
End If
Next
End Sub
'*************************************************************
Sub unregisterEvents
Script.UnregisterEvents SDB
End Sub
'*************************************************************
'These are what the full JSON strings look like that need to be sent to slimRequest()
'formatRequest() fills in the first part and all you have to do is pick the RPC commands from http://svn.slimdevices.com/repos/slim/7.5/trunk/server/Slim/Control/Request.pm
'Note: there are cleaner ways of doing this - but this is quick and dirty. It just means that you have to use a lot of """ and etc in vbscript.
'This entire script is much easier to write in jscript but I don't know jscript at all so, shrug.
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["status","-",1,"tags:cgABbehldiqtyrSuoKLN"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["status","-",1,"tags:uB"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["playlist","index",28]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["pause"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",[""playlist"", ""play"", ""D:\\MP3\\filename.mp3""]]}
'You can do ANYTHING you can do from the web interface via this RPC engine because you are directly calling the methods in Perl
'so you could add whole playlists and etc see the docs. Sky's the limit.
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.1.0.
Latest Beta release V3.1.0.150518
It's been a while, here is the latest beta!!
The current version of the script is optimised for MediaMonkey 4 and above.
If you haven't used a Beta just follow the instructions below, it's easy. Try a Beta, they're safe and you'll be helping with the development.
Release improvements:
- Added the ability to log into a password protected LMS/Squeezebox system. Data entered on the MonkeySqueeze Options page.
- Roll back to V3.0.1 - Changes in V3.0.1.120314Beta removed.
Known Issues:
None at this stage. Make sure you read the tool tips on the options page.
To use this version:
Copy the script to Notepad and save as MonkeySqueeze.vbs to one one of the following locations:
C:\Program Files\MediaMonkey\Scripts\Auto or C:\Program Files (x86)\MediaMonkey\Scripts\Auto
Make sure you disable or remove the existing MonkeySqueeze.vbs
If you use this script please report on this forum if it runs OK or if you had any issues. Feedback is appreciated so I can implement changes before any official release.
It's been a while, here is the latest beta!!
The current version of the script is optimised for MediaMonkey 4 and above.
If you haven't used a Beta just follow the instructions below, it's easy. Try a Beta, they're safe and you'll be helping with the development.
Release improvements:
- Added the ability to log into a password protected LMS/Squeezebox system. Data entered on the MonkeySqueeze Options page.
- Roll back to V3.0.1 - Changes in V3.0.1.120314Beta removed.
Known Issues:
None at this stage. Make sure you read the tool tips on the options page.
To use this version:
Copy the script to Notepad and save as MonkeySqueeze.vbs to one one of the following locations:
C:\Program Files\MediaMonkey\Scripts\Auto or C:\Program Files (x86)\MediaMonkey\Scripts\Auto
Make sure you disable or remove the existing MonkeySqueeze.vbs
If you use this script please report on this forum if it runs OK or if you had any issues. Feedback is appreciated so I can implement changes before any official release.
Code: Select all
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'
' MonkeySqueeze V3.1.0.150518Beta
'
' MOD DATE: 13.05.2018
'
' Script: Development has occurred in two distinct stages: As Squeezebox Controller from 2007 to 2009; and as MonkeySqueeze from 2011 on.
'
' ORIGINAL AUTHOR: Todd Nemeth/revel
' DATE STARTED: 26.09.2007
'
' Squeezebox Controller: Todd Nemeth Mods: Baz, Big_Berny, Peke, trixmoto, debacle, mccstumble
' MonkeySqueeze: Gingernut63, booblers, Katteman
'
' COMMENT:
' - You will also need Logitech Media Server (SqueezeBox Server) installed and running
' - Optional: Install and run SqueezePlay or SoftSqueeze
' - After installation the options page for this script is located at Tools > Options > MonkeySqueeze
'
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Option Explicit
Public EndOfTrack, LMScount, LMSpaths()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim onMonkeySqueezeIcon
Dim offMonkeySqueezeIcon
'**************************************************************
Sub OnStartup
Dim ind, Mnu
Dim UI : Set UI = SDB.UI
onMonkeySqueezeIcon = SDB.RegisterIcon("Scripts\Auto\sbon.ico", 0)
If onMonkeySqueezeIcon < 0 Then
onMonkeySqueezeIcon = 74 'unlocked icon if it doesn't exist
End If
offMonkeySqueezeIcon = SDB.RegisterIcon("Scripts\Auto\sboff.ico", 0)
If offMonkeySqueezeIcon < 0 Then
offMonkeySqueezeIcon = 75 'locked icon if it doesn't exist
End If
Set Mnu = UI.AddMenuItem( UI.Menu_TbStandard, 0, 0)
Mnu.Caption = "MonkeySqueeze"
Mnu.UseScript = Script.ScriptPath
Mnu.OnClickFunc = "SyncToggle"
Mnu.IconIndex = offMonkeySqueezeIcon
Mnu.Hint = "Enable/Disable MonkeySqueeze"
Set SDB.Objects("MonkeySqueezeIcon") = Mnu 'save a reference to it so we can change the icon later.
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False
ind = SDB.UI.AddOptionSheet("MonkeySqueeze",Script.ScriptPath,"InitSheet","SaveSheet",-2)
'logme(slimRequest(formatCommand("""version"",""?""")))
End Sub
'**************************************************************
Sub InitSheet(Sheet)
Dim Panel1, Panel2, Checkbox3, Checkbox4, Edit6, Edit7, Panel3, Edit1, Panel4, Btn1, Edit2, Panel5, Edit3, Edit4, Edit5, Checkbox1, Checkbox2
Set Panel1 = SDB.UI.NewGroupBox(Sheet)
Panel1.Common.SetRect 10,10,450,50
Panel1.Caption = "MonkeySqueeze v3.1.0.150518Beta"
With SDB.UI.NewLabel(Panel1)
.Common.SetRect 15,22,590,20
.Caption = "This script allows MediaMonkey to play music on a SqueezeBox system"
End With
Set Btn1 = SDB.UI.NewButton(Panel1)
Btn1.Common.SetRect 370,15,65,25
Btn1.Caption = "User Guide"
Btn1.Common.Hint = "Click and then open MonkeySqueeze_UserGuide.pdf"
Script.RegisterEvent Btn1, "OnClick", "UserGuide"
Set Panel2 = SDB.UI.NewGroupBox(Sheet)
Panel2.Common.SetRect 10,70,450,80
Panel2.Caption = "General Settings"
Set CheckBox3 = SDB.UI.NewCheckBox(Panel2)
CheckBox3.Common.SetRect 15,20,150,20
CheckBox3.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle")
CheckBox3.Common.ControlName = "EnablePT"
CheckBox3.Common.Hint = SDB.Localize("When selected if MonkeySqueeze is enabled, the primary SqueezeBox device will power on, and on/off at startup/shutdown. When MonkeySqueeze is disabled, primary SqueezeBox device will power off. Does not work if SqueezePlay is the primary device.")
CheckBox3.Caption = SDB.Localize("Enable Power Toggle")
Set CheckBox4 = SDB.UI.NewCheckBox(Panel2)
CheckBox4.Common.SetRect 15,50,80,20
CheckBox4.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","Login")
CheckBox4.Common.ControlName = "EnableLog"
CheckBox4.Common.Hint = SDB.Localize("This will enable MonkeySqueeze to log into a password protected LMS/SqueezeBox system.")
CheckBox4.Caption = SDB.Localize("Enable Login")
Script.RegisterEvent CheckBox4.Common, "OnClick", "LogClick"
With SDB.UI.NewLabel(Panel2)
.Common.SetRect 115,53,60,20
.Caption = "Username:"
End With
Set Edit6 = SDB.UI.NewEdit(Panel2)
Edit6.Common.ControlName = "SqueezeBoxUser"
Edit6.Common.SetRect 172,50,95,25
Edit6.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxUser")
If Edit6.Text = "" Then
Edit6.Text = ""
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxUser") = ""
End If
Edit6.Common.Hint = "Type the LMS username here"
With SDB.UI.NewLabel(Panel2)
.Common.SetRect 280,53,60,20
.Caption = "Password:"
End With
Set Edit7 = SDB.UI.NewEdit(Panel2)
Edit7.Common.ControlName = "SqueezeBoxPass"
Edit7.Common.SetRect 334,50,95,25
Edit7.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPass")
If Edit7.Text = "" Then
Edit7.Text = ""
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPass") = ""
End If
Edit7.PasswordChar = "*"
Edit7.Common.Hint = "Type the LMS password here"
Edit6.Common.Enabled = CheckBox4.Checked
Edit7.Common.Enabled = CheckBox4.Checked
Set Panel3 = SDB.UI.NewGroupBox(Sheet)
Panel3.Common.SetRect 10,160,450,125
Panel3.Caption = "LMS IP Address and HTTP Port"
With SDB.UI.NewLabel(Panel3)
.Multiline = True
.Common.SetRect 15,20,420,50
.Caption = "Open the LMS (SqueezeBox Server) Web Control page > Settings > Information tab and find the Server IP Address, e.g. 192.168.0.102 and enter below. The default HTTP Port number is 9000. See user guide if you wish to change it."
End With
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 15,74,70,20
.Caption = "IP Address:"
End With
Set Edit1 = SDB.UI.NewEdit(Panel3)
Edit1.Common.ControlName = "SqueezeBoxIP"
Edit1.Common.SetRect 75,70,95,25
Edit1.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP")
If Edit1.Text = "" Then
Edit1.Text = "XXX.XXX.XXX.XXX"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") = "XXX.XXX.XXX.XXX"
End If
Edit1.Common.Hint = "Copy and paste the LMS IP Address or Hostname here"
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 215,74,70,20
.Caption = "HTTP Port No:"
End With
Set Edit2 = SDB.UI.NewEdit(Panel3)
Edit2.Common.ControlName = "SqueezeBoxPort"
Edit2.Common.SetRect 287,70,40,25
Edit2.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort")
If Edit2.Text = "" Then
Edit2.Text = "9000"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") = "9000"
End If
Edit2.Common.Hint = "HTTP port default is 9000. View the port number in LMS: Web Control page > Settings > Information tab and change if required"
With SDB.UI.NewLabel(Panel3)
.Common.SetRect 15,100,450,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
Set Panel4 = SDB.UI.NewGroupBox(Sheet)
Panel4.Common.SetRect 10,295,450,125
Panel4.Caption = "Primary SqueezeBox Device - MAC Address"
With SDB.UI.NewLabel(Panel4)
.Multiline = True
.Common.SetRect 15,20,420,60
.Caption = "The MAC address of the device (Touch, SqueezePlay, etc...) you wish to connect to. Open the LMS Web Control page > Settings page > Information tab and find the device. Enter the MAC address, e.g. z1:6d:4g:40:1f:32"
End With
With SDB.UI.NewLabel(Panel4)
.Common.SetRect 15,74,70,20
.Caption = "Device MAC Address:"
End With
Set Edit3 = SDB.UI.NewEdit(Panel4)
Edit3.Common.ControlName = "SqueezeBoxMAC"
Edit3.Common.SetRect 122,70,110,25
Edit3.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC")
If Edit3.Text = "" Then
Edit3.Text = "xx:xx:xx:xx:xx:xx"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") = "xx:xx:xx:xx:xx:xx"
End If
Edit3.Common.Hint = "Copy and paste the MAC address here. Use lowercase text for maximum compatibility"
With SDB.UI.NewLabel(Panel4)
.Common.SetRect 15,100,420,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
Set Panel5 = SDB.UI.NewGroupBox(Sheet)
Panel5.Common.SetRect 10,430,450,165
Panel5.Caption = "LMS on a Linux or Windows Server/NAS"
With SDB.UI.NewLabel(Panel5)
.Multiline = True
.Common.SetRect 15,20,420,60
.Caption = "For Linux devices the media folder address in LMS uses forward slashes. e.g. /media/Music. Windows devices use back slashes (\) for all addresses"
End With
Set CheckBox1 = SDB.UI.NewCheckBox(Panel5)
CheckBox1.Common.SetRect 15,53,120,20
CheckBox1.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","NAS")
CheckBox1.Common.ControlName = "EnableNAS"
CheckBox1.Common.Hint = SDB.Localize("Select if using LMS on a Linux or Windows Server/NAS device. See user guide for more details")
CheckBox1.Caption = SDB.Localize("Enable Server/NAS")
Script.RegisterEvent CheckBox1.Common, "OnClick", "NASClick"
Set CheckBox2 = SDB.UI.NewCheckBox(Panel5)
CheckBox2.Common.SetRect 200,53,260,20
CheckBox2.Checked = SDB.IniFile.BoolValue("MonkeySqueeze","Synology")
CheckBox2.Common.ControlName = "EnableSynology"
CheckBox2.Common.Hint = SDB.Localize("Select if using Squeezebox Server prior to v7.5.1. Tested on Synology devices only")
CheckBox2.Caption = SDB.Localize("LMS is prior to v7.5.1 (Linux device only)")
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,84,70,20
.Caption = "MediaMonkey Music Folder:"
End With
Set Edit4 = SDB.UI.NewEdit(Panel5)
Edit4.Common.ControlName = "MediaMonkeyMF"
Edit4.Common.SetRect 148,80,283,25
Edit4.Text = SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF")
If Edit4.Text = "" Then
Edit4.Text = "\\Server\folder or X:\__\__(mapped)"
SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF") = "\\Server\folder or X:\__\__(mapped)"
End If
Edit4.Common.Hint = "Copy from MediaMonkey > File > Add/Rescan Folders or the Path column in the Track Browser section"
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,114,70,20
.Caption = "LMS Media Folder:"
End With
Set Edit5 = SDB.UI.NewEdit(Panel5)
Edit5.Common.ControlName = "SqueezeBoxMF"
Edit5.Common.SetRect 105,110,283,25
Edit5.Text = SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF")
If Edit5.Text = "" Then
Edit5.Text = "/___ /___ Linux, or \ ___\ ___ Windows"
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF") = "/___ /___ Linux, or \ ___\ ___ Windows"
End If
Edit5.Common.Hint = "Copy and Paste from: LMS Web Page > Settings > Basic Settings tab > Music Folder"
With SDB.UI.NewLabel(Panel5)
.Common.SetRect 15,140,420,20
.Caption = "Press OK and restart the music for the changes to take effect."
End With
CheckBox2.Common.Enabled = CheckBox1.Checked
Edit4.Common.Enabled = CheckBox1.Checked
Edit5.Common.Enabled = CheckBox1.Checked
End Sub
'**************************************************************
Sub LogClick(ChB)
Dim Edt6, Edt7
Set Edt6 = ChB.Common.TopParent.Common.ChildControl("SqueezeBoxUser")
Set Edt7 = ChB.Common.TopParent.Common.ChildControl("SqueezeBoxPass")
Edt6.Common.Enabled = ChB.Checked
Edt7.Common.Enabled = ChB.Checked
End Sub
'**************************************************************
Sub NASClick(ChB)
Dim ChB2, Edt4, Edt5
Set ChB2 = ChB.Common.TopParent.Common.ChildControl("EnableSynology")
Set Edt4 = ChB.Common.TopParent.Common.ChildControl("MediaMonkeyMF")
Set Edt5 = ChB.Common.TopParent.Common.ChildControl("SqueezeBoxMF")
ChB2.Common.Enabled = ChB.Checked
Edt4.Common.Enabled = ChB.Checked
Edt5.Common.Enabled = ChB.Checked
End Sub
'**************************************************************
Sub SaveSheet(Sheet)
SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") = Sheet.Common.ChildControl( "EnablePT").Checked
SDB.IniFile.BoolValue("MonkeySqueeze","Login") = Sheet.Common.ChildControl( "EnableLog").Checked
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxUser") = Sheet.Common.ChildControl("SqueezeBoxUser").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPass") = Sheet.Common.ChildControl("SqueezeBoxPass").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") = Sheet.Common.ChildControl("SqueezeBoxIP").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") = Sheet.Common.ChildControl("SqueezeBoxPort").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") = Sheet.Common.ChildControl("SqueezeBoxMAC").Text
SDB.IniFile.BoolValue("MonkeySqueeze","NAS") = Sheet.Common.ChildControl( "EnableNAS").Checked
SDB.IniFile.BoolValue("MonkeySqueeze","Synology") = Sheet.Common.ChildControl( "EnableSynology").Checked
SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF") = Sheet.Common.ChildControl("MediaMonkeyMF").Text
SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF") = Sheet.Common.ChildControl("SqueezeBoxMF").Text
End Sub
'**************************************************************
Sub UserGuide
On Error Resume Next
Dim OF, FolderToOpen
Set OF = CreateObject("Shell.Application")
FolderToOpen = sdb.ScriptsPath & "Auto\"
OF.Explore FolderToOpen
Set OF = Nothing
End Sub
'**************************************************************
Function SqueezeBoxMode
Dim strRetVal
On Error Resume Next
SqueezeBoxMode = ""
strRetVal = slimRequest(formatCommand("""mode"", ""?"""))
If InStrRev(strRetVal, "play") > 0 Then
SqueezeBoxMode = "play"
ElseIf InStrRev(strRetVal, "stop") > 0 Then
SqueezeBoxMode = "stop"
ElseIf InStrRev(strRetVal, "pause") > 0 Then
SqueezeBoxMode = "pause"
End If
End Function
'**************************************************************
Sub ShowPlayerSettings
Dim Plr, Warning, Res
Warning = ""
Set Plr = SDB.Player
'If Plr.isAutoDJ Then Warning = Warning & vbNewLine & "AutoDJ is on"
If Plr.isCrossFade Then Warning = Warning & vbNewLine & "CrossFade is on"
If Plr.isShuffle Then Warning = Warning & vbNewLine & "Shuffle is on"
If Plr.isEqualizer Then Warning = Warning & vbNewLine & "Equalizer is on"
If Plr.isRepeat Then Warning = Warning & vbNewLine & "Repeat is on"
If Warning <> "" Then
Res = SDB.MessageBox("Selected player settings:" & vbNewLine & _
Warning, mtWarning, Array(mbOk))
End If
End Sub
'**************************************************************
Function SyncToggle( itm )
If SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False Then
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = True
itm.IconIndex = SDB.RegisterIcon("Scripts\Auto\sbon.ico", 0)
Call registerEvents
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""1"""))
ShowPlayerSettings
FillPlaylist
Else
SDB.IniFile.BoolValue("MonkeySqueeze","SyncToggle") = False
itm.IconIndex = SDB.RegisterIcon("Scripts\Auto\sboff.ico", 0)
Call unregisterEvents
slimRequest(formatCommand("""stop"""))
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""0"""))
End If
End Function
'**************************************************************
Sub Event_OnPlay
Dim strRetVal, Idx
If (SqueezeBoxMode = "play") And EndOfTrack Then
'*** normal playlist continuation
EndOfTrack = False
Else
'*** SqueezeBox is not playing or new track out of order
Idx = SDB.Player.CurrentSongIndex
slimRequest(formatCommand("""playlist"", ""index"", """ + Cstr(Idx) + """"))
End If
End Sub
'**************************************************************
Sub Event_OnTrackEnd
Dim strRetVal, idx, tim, dur
'*** see if current track ended, then playing is not interrupted
EndOfTrack = True
End Sub
'**************************************************************
Function CheckPath(SongValue)
If Left(SongValue.Path,1) = "?" Then
If SongValue.Cached Then
CheckPath = SongValue.CachedPath
Else
CheckPath = SongValue.Path
End If
Else
CheckPath = SongValue.Path
End If
If SDB.IniFile.BoolValue("MonkeySqueeze","NAS") Then
If SDB.IniFile.BoolValue("MonkeySqueeze","Synology") Then CheckPath = Replace(CheckPath,"\","/")
CheckPath = Replace(CheckPath,SDB.IniFile.StringValue("MonkeySqueeze","MediaMonkeyMF"),SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMF"))
End If
End Function
'**************************************************************
Sub Event_OnStop
slimRequest(formatCommand("""stop"""))
End Sub
'**************************************************************
Sub Event_OnShutdown
On Error Resume Next
slimRequest(formatCommand("""stop"""))
If SDB.IniFile.BoolValue("MonkeySqueeze","PowerToggle") Then slimRequest(formatCommand("""power"", ""0"""))
End Sub
'**************************************************************
Sub Event_OnPause
If SDB.Player.IsPaused Then
slimRequest(formatCommand("""pause"""))
Else
slimRequest(formatCommand("""play"""))
End If
End Sub
'**************************************************************
Sub Event_OnSeek
Dim SBmode, Song, TrackPath, LMStime
SBmode = SqueezeBoxMode
If SBmode = "stop" Then
Set Song = SDB.Player.CurrentSong
TrackPath = CheckPath(Song)
slimRequest(formatCommand("""playlist"", ""play"", """ + perlEscape(TrackPath) + """"))
End If
LMStime = 0.001 * SDB.Player.PlaybackTime
slimRequest(formatCommand("""time"", """ + CStr(LMStime) + """"))
End Sub
'**************************************************************
Function slimRequest(params)
'slimRequest accepts pre-formatted parameter string, returns string of the response'
'logme " >> slimRequest: Begin with " + params
Dim url, prog, objHTTP
Dim cnt : cnt = 0
If SDB.IniFile.BoolValue("MonkeySqueeze","Login") = True Then
url = "http://" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxUser") + ":" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPass") + "@" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") + ":" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") + "/jsonrpc.js"
Else
url = "http://" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxIP") + ":" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxPort") + "/jsonrpc.js"
End If
'Set prog = SDB.Objects("LoadXMLBar")
Set prog = SDB.Progress
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
Call objHTTP.open("POST", url, True)
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.setRequestHeader "X-Requested-With", "XMLHttpRequest"
objHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"
objHTTP.send(params)
Do While (objHTTP.readyState < 4) And (cnt < 300)
Call SDB.Tools.Sleep(100)
SDB.ProcessMessages
cnt = cnt+1
If prog.Terminate Then
cnt = 300
End If
Loop
If objHTTP.readyState < 4 Then
Set slimRequest = Nothing
Else
slimRequest = objHTTP.responseText
End If
End Function
'*************************************************************
'This is is a JSON RPC call - We're directly calling functions in the Slim::Request module in Perl. See here:
'http://svn.slimdevices.com/repos/slim/7.5/trunk/server/Slim/Control/Request.pm
'the addDispatch section tells you how to use the commands and what the RPC module is looking for in terms of formatting
Function formatCommand(str1)
formatCommand = "{""id"":1,""method"":""slim.request"",""params"":[""" + SDB.IniFile.StringValue("MonkeySqueeze","SqueezeBoxMAC") + """,[" + str1 + "]]}"
End Function
'*************************************************************
'borrowed from a teknojunky - if you want the popups add them to this and then just call logme
Sub logme(msg)
Dim fso, logf
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set logf = fso.OpenTextFile(Script.ScriptPath&".log",ForAppending,True)
logf.WriteLine Now() & ": " & msg
Set fso = Nothing
Set logf = Nothing
End Sub
'*************************************************************
'Perl is taking the JSON strings directly into variables - "\" is a special character in perl to escape the following string
'wherever we have a "\" we need it to be "\\" in anything that goes to Perl (ie: anything that goes to SqueezeBox)
Function perlEscape(str1)
perlEscape = Replace(str1, "\", "\\")
End Function
'*************************************************************
Sub registerEvents
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnSeek","Event_OnSeek")
Call Script.RegisterEvent(SDB,"OnTrackEnd","Event_OnTrackEnd")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnNowPlayingModified","Event_OnNowPlayingModified")
End Sub
'*************************************************************
Sub Event_OnNowPlayingModified
Dim MMcount
MMcount = SDB.Player.CurrentPlayList.Count
'logme("Now playing modified")
'logme("Aantal MM tracks: " & Cstr(MMcount))
'logme("Aantal LMS tracks: " & Cstr(LMScount))
If SqueezeBoxMode = "stop" Then
FillPlaylist
ElseIf MMcount = 0 Then
ResetPlaylist
ElseIf MMcount < LMScount Then
TracksDeleted(MMcount)
ElseIf MMcount > LMScount Then
TracksAdded(MMcount)
Else
TracksMoved
End If
End Sub
'*************************************************************
Sub FillPlaylist
'*** synchronize MM playlist with LMS playlist
Dim tempStop, Idx
'*** clear LMS playlist and stop shuffle!!
slimRequest(formatCommand("""playlist"", ""clear"""))
slimRequest(formatCommand("""playlist"", ""shuffle"", ""0"""))
'*** copy MM playlist - if any - to LMS
LMScount = SDB.Player.CurrentPlayList.Count
ReDim LMSpaths(LMScount)
'*** if playlist is empty we are done
If LMScount > 0 Then
tempStop = SDB.Player.isPlaying And (SDB.Player.PlayBackTime < 2000)
If tempStop Then
SDB.Player.pause
slimRequest(formatCommand("""stop"""))
End If
SendPlaylist
'*** jump to current song
Idx = SDB.Player.CurrentSongIndex
slimRequest(formatCommand("""playlist"", ""index"", """ + Cstr(Idx) + """"))
If tempStop Then
'*** Start playback after filling playlist
SDB.Player.Pause
ElseIf SDB.Player.isPlaying Then
'*** Synchronize LMS with current track
slimRequest(formatCommand("""time"", """ + CStr(SDB.Player.PlaybackTime*0.001) + """"))
If SDB.Player.isPaused Then SDB.Player.Pause
Else
'*** MediaMonkey is not playing
slimRequest(formatCommand("""stop"""))
End If
End If
EndOfTrack = False
End Sub
'**************************************************************
Sub SendPlaylist
Dim Progr, TrackPath, Song, n
'*** show progress bar
Set Progr = SDB.Progress
Progr.Text = SDB.Localize("Synchronising playlists...")
Progr.MaxValue = LMScount
'*** send playlist
For n=0 To LMScount-1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
LMSpaths(n) = TrackPath
slimRequest(formatCommand("""playlist"", ""add"", """ + perlEscape(TrackPath) + """"))
Progr.Value = n+1
Next
End Sub
'**************************************************************
Sub ResetPlaylist
SDB.Player.Stop
slimRequest(formatCommand("""stop"""))
slimRequest(formatCommand("""playlist"", ""clear"""))
ReDim LMSpaths(0)
LMScount = 0
End Sub
'**************************************************************
Sub TracksDeleted(MMcount)
Dim n, m, Song, TrackPath
'logme("Tracks deleted")
n = 0
Do While MMcount < LMScount
If n = MMcount Then
TrackPath = "***"
Else
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
End If
If (TrackPath = LMSpaths(n)) Then
n = n+1
Else
LMScount = LMScount - 1
For m = n To LMScount - 1
LMSpaths(m) = LMSpaths(m+1)
Next
slimRequest(formatCommand("""playlist"", ""delete"", """ + Cstr(n) + """"))
End If
Loop
End Sub
'*************************************************************
Sub TracksAdded(MMcount)
Dim n, m, Song, TrackPath
'logme("Tracks added")
ReDim Preserve LMSpaths(MMcount) 'expand array, preserve content
Do
For n = 0 to MMcount -1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
If (TrackPath <> LMSpaths(n)) Then
slimRequest(formatCommand("""playlist"", ""add"", """ + perlEscape(TrackPath) + """"))
If n < LMScount Then
slimRequest(formatCommand("""playlist"", ""move"", """ + Cstr(LMScount) + """, """ + Cstr(n) + """"))
For m = LMScount To n+1 Step -1
LMSpaths(m) = LMSpaths(m-1)
Next
End If
LMSpaths(n) = TrackPath
LMScount = LMScount + 1
End If
Next
Loop While MMcount > LMScount
End Sub
'*************************************************************
Sub TracksMoved
Dim n, m, i, Song, TrackPath, tempPath
'logme("Tracks moved")
For n=0 To LMScount-1
Set Song = SDB.Player.CurrentPlayList.Item(n)
TrackPath = CheckPath(Song)
If TrackPath <> LMSpaths(n) Then
For m=n+1 To LMScount-1
If TrackPath = LMSpaths(m) Then Exit For
Next
For i=m To n+1 Step -1
LMSpaths(i) = LMSpaths(i-1)
Next
LMSpaths(n) = TrackPath
slimRequest(formatCommand("""playlist"", ""move"", """ + Cstr(m) + """, """ + Cstr(n) + """"))
End If
Next
End Sub
'*************************************************************
Sub unregisterEvents
Script.UnregisterEvents SDB
End Sub
'*************************************************************
'These are what the full JSON strings look like that need to be sent to slimRequest()
'formatRequest() fills in the first part and all you have to do is pick the RPC commands from http://svn.slimdevices.com/repos/slim/7.5/trunk/server/Slim/Control/Request.pm
'Note: there are cleaner ways of doing this - but this is quick and dirty. It just means that you have to use a lot of """ and etc in vbscript.
'This entire script is much easier to write in jscript but I don't know jscript at all so, shrug.
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["status","-",1,"tags:cgABbehldiqtyrSuoKLN"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["status","-",1,"tags:uB"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["playlist","index",28]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",["pause"]]}
'{"id":1,"method":"slim.request","params":["00:04:20:17:06:xx",[""playlist"", ""play"", ""D:\\MP3\\filename.mp3""]]}
'You can do ANYTHING you can do from the web interface via this RPC engine because you are directly calling the methods in Perl
'so you could add whole playlists and etc see the docs. Sky's the limit.
Last edited by Gingernut63 on Mon May 25, 2015 12:21 am, edited 6 times in total.
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
Re: MonkeySqueeze Development V3.0.2.
Hi,
I loaded 3.0.1.150513Beta, and I receive no error messages what so ever. All seems to work just fine, but nothing plays although the progress bar is running normally, so obviously MM believes that the song is playing.
If I disable Logon in MonkeySqueeze and disable password protection in LMS, everything works just fine.
Any Ideas?
I loaded 3.0.1.150513Beta, and I receive no error messages what so ever. All seems to work just fine, but nothing plays although the progress bar is running normally, so obviously MM believes that the song is playing.
If I disable Logon in MonkeySqueeze and disable password protection in LMS, everything works just fine.
Any Ideas?
-
- Posts: 236
- Joined: Thu Jul 14, 2011 4:13 am
Re: MonkeySqueeze Development V3.0.2.
Yes, there is probably a space before or after the username and password that is there from the coding (now fixed in the beta). On the options page place the cursor to the far right of the username and password (including any space that may be there) and backspace as far as it will go and then enter them again.oeyoeve wrote:Hi,
I loaded 3.0.1.150513Beta, and I receive no error messages what so ever. All seems to work just fine, but nothing plays although the progress bar is running normally, so obviously MM believes that the song is playing.
If I disable Logon in MonkeySqueeze and disable password protection in LMS, everything works just fine.
Any Ideas?
MonkeySqueeze – Squeezing music into your life!
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005
https://twitter.com/#!/MonkeySqueeze1
MonkeySqueeze Support: http://www.mediamonkey.com/forum/viewto ... =2&t=59515
MonkeySqueeze Development: http://www.mediamonkey.com/forum/viewto ... 19&t=59907
MediaMonkey user since 2005