Re: Slimdevices Squeezebox / Squeezecenter Support (Plugin)
Posted: Thu Jun 02, 2011 5:14 am
Hi All,
I hope this may be of help to some of you....
I have been using the script below (+ a few modifications to it obtained from the clever people on the forums) for a few years now. I have it as a text file in "C:\Program Files\MediaMonkey\Scripts\Auto" (ie where mediamonkey is installed).
If my memory serves me correctly the original developer got the script so far and then gave up in favour of other interests. Needless to say a few others picked up where he left off and what is pasted below works a treat for me.
I have Squeezebox server (currently Version: 7.5.4 - r32171) installed on my Vista laptop and it looks at my music collection on an attached Portable Hard Disk Drive. This was fine for simply playing music to my various Squeezeboxes and initially I thought it was great. But, as so many have commented Squeezebox Server is not ideal for Library Management and things like tagging files etc.
As a separate activity I have Mediamonkey looking at the same music collection on the Portable Hard Disk Drive and I use Mediamonkey to manage the collection. (ie one collection of music files which I think is one library?). Anyway - any changes I make via Mediamonkey (ie album art, titles etc) are committed to the individual files.
The problem was that Mediamonkey only played on the laptop and didn't "talk" to Squeezebox Server. This is where the script came in and resolved the problem
The script means that when Mediamonkey starts it "somehow" sends the currently playing song to Squeezebox Server and it turn to my Squeezeboxes. Even better is that when I am using Mediamonkey whatever I play or fast-forward, rewind, pause or stop is transferred to the Squeezebox Server.
I also have iPeng set up on my iPod Touch which is great as a controller for Squeezebox Server (and much better than using the original remote control that came with my Squeezebox Duet).
Also on my iPod Touch I use the Apple App "Remote" which can control Mediamonkey using Mellorware's "MonkeyTunes" (http://melloware.com/products/monkeytunes/). So this means I can Run Mediamonkey on my laptop but control it remotely using "Remote" via Monkeytunes and at the same time have it playing on my Squeezeboxes. If I want to then view related information such as Artist Biography etc I just switch to iPeng to get the info
So here is the script I have been using for a few years now. Just copy it in it's entirety and save it to the Mediamonkey AutoScripts folder. You will need to edit the IP Address of your Squeezebox Server. A bit of a pain is that if the IP changes later you need to locate the file and ammend it with the new IP address. Apart form that it runs like a dream. Not perfect but I mostly forget it is there.
To edit the IP address just look for and overtype the "X's" with your Squeezebox Server's IP Address. You will find this information on the "Settings Page" and "Information" tab of your Squeezebox Server under "Server IP Address"
I hope this may be of help to some of you....
I have been using the script below (+ a few modifications to it obtained from the clever people on the forums) for a few years now. I have it as a text file in "C:\Program Files\MediaMonkey\Scripts\Auto" (ie where mediamonkey is installed).
If my memory serves me correctly the original developer got the script so far and then gave up in favour of other interests. Needless to say a few others picked up where he left off and what is pasted below works a treat for me.
I have Squeezebox server (currently Version: 7.5.4 - r32171) installed on my Vista laptop and it looks at my music collection on an attached Portable Hard Disk Drive. This was fine for simply playing music to my various Squeezeboxes and initially I thought it was great. But, as so many have commented Squeezebox Server is not ideal for Library Management and things like tagging files etc.
As a separate activity I have Mediamonkey looking at the same music collection on the Portable Hard Disk Drive and I use Mediamonkey to manage the collection. (ie one collection of music files which I think is one library?). Anyway - any changes I make via Mediamonkey (ie album art, titles etc) are committed to the individual files.
The problem was that Mediamonkey only played on the laptop and didn't "talk" to Squeezebox Server. This is where the script came in and resolved the problem
The script means that when Mediamonkey starts it "somehow" sends the currently playing song to Squeezebox Server and it turn to my Squeezeboxes. Even better is that when I am using Mediamonkey whatever I play or fast-forward, rewind, pause or stop is transferred to the Squeezebox Server.
I also have iPeng set up on my iPod Touch which is great as a controller for Squeezebox Server (and much better than using the original remote control that came with my Squeezebox Duet).
Also on my iPod Touch I use the Apple App "Remote" which can control Mediamonkey using Mellorware's "MonkeyTunes" (http://melloware.com/products/monkeytunes/). So this means I can Run Mediamonkey on my laptop but control it remotely using "Remote" via Monkeytunes and at the same time have it playing on my Squeezeboxes. If I want to then view related information such as Artist Biography etc I just switch to iPeng to get the info
So here is the script I have been using for a few years now. Just copy it in it's entirety and save it to the Mediamonkey AutoScripts folder. You will need to edit the IP Address of your Squeezebox Server. A bit of a pain is that if the IP changes later you need to locate the file and ammend it with the new IP address. Apart form that it runs like a dream. Not perfect but I mostly forget it is there.
To edit the IP address just look for and overtype the "X's" with your Squeezebox Server's IP Address. You will find this information on the "Settings Page" and "Information" tab of your Squeezebox Server under "Server IP Address"
Code: Select all
'==========================================================================
' NAME: SqueezeBox Controller
'
' ORIGINAL AUTHOR: Todd Nemeth /revel
' DATE STARTED: 26.09.2007
'
' ADDITIONAL AUTHORS: Baz, Big_Berny, Peke, trixmoto
' UPDATE DATE: 28.02.2008
'
' COMMENT:
'- You need w3Sockets installed and registered from here:
' http://www.dimac.net/default3.asp?M=FreeDownloads/'Menu.asp&P=FreeDownloads/FreeDownloadsstart.asp
'- You will also need SlimServer installed and running.'
'==========================================================================
Option Explicit
Public SqueezeBoxSocket
Public ManualTrackChange
Sub OnStartup
Dim ind
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,"OnShutdown","Event_OnShutdown")
' Call Script.RegisterEvent(SDB,"OnTrackEnd","Event_OnTrackEnd")
' Call Script.RegisterEvent(SDB,"OnPlaybackEnd","Event_OnPlaybackEnd")
' Call Script.RegisterEvent(SDB,"OnIdle","Event_OnIdle")
ind = SDB.UI.AddOptionSheet("SqueezeBox Controller",Script.ScriptPath,"InitSheet","SaveSheet",-2)
InitSqueezeBox
ManualTrackChange = True
Call SDB.Player.Play
End Sub
Sub InitSheet( Sheet)
Dim UI : Set UI = SDB.UI
Dim LabelAbout : Set LabelAbout = UI.NewLabel(Sheet)
LabelAbout.Multiline = True
LabelAbout.Common.SetRect 5,5,470,40
LabelAbout.Common.Anchors = 4
LabelAbout.Caption = "This small script will add ability to Control SqueezeBox using MediaMonkey Playback Controls"
Dim Label1 : Set Label1 = UI.NewLabel(Sheet)
Label1.Autosize = True
Label1.Common.SetRect 10,31,65,20
Label1.Common.Anchors = 4
Label1.Caption = SDB.Localize("SlimServer IP:")
Label1.Common.Hint = "Local IP address where SlimServer is Installed (127.0.0.1, 192.168.1.10, ...)"
Dim Edit1 : Set Edit1 = UI.NewEdit(Sheet)
Edit1.Common.ControlName = "SqueezeBoxIP"
Edit1.Common.SetRect 85,27,121,20
Edit1.Text = SDB.IniFile.StringValue("SqueezeBox","IP")
If Edit1.Text = "" Then
Edit1.Text = "127.0.0.1"
SDB.IniFile.StringValue("SqueezeBox","IP") = "127.0.0.1"
End If
Edit1.Common.Anchors = 1
Edit1.Common.Hint = "Enter Local IP address where SlimServer is Installed (127.0.0.1, 192.168.1.10, ...)"
End Sub
Sub SaveSheet(Sheet)
SDB.IniFile.StringValue("SqueezeBox","IP") = Sheet.Common.ChildControl("SqueezeBoxIP").Text
End Sub
Sub InitSqueezeBox
On Error Resume Next
Set SqueezeBoxSocket = CreateObject("Socket.TCP")
SqueezeBoxSocket.DoTelnetEmulation = True
SqueezeBoxSocket.TelnetEmulation = "TTY"
SqueezeBoxSocket.Host = "XXX.XXX.X.XX:9090"
SqueezeBoxSocket.Open
End Sub
Sub CloseSqueezeBox
On Error Resume Next
SqueezeBoxSocket.Close
End Sub
Sub SendSqueezeBoxCmd(strPlayerCmd)
On Error Resume Next
SqueezeBoxSocket.SendLine strPlayerCmd
' Call ReadSqueezeBoxLine
End Sub
Sub ReadSqueezeBoxLine
On Error Resume Next
Dim line
line = SqueezeBoxSocket.GetLine
End Sub
Function SqueezeBoxMode
On Error Resume Next
SqueezeBoxMode = ""
' SqueezeBoxSocket.SendLine "mode ?"
' SqueezeBoxMode = SqueezeBoxSocket.GetLine
End Function
Function Max(a,b)
If a > b Then
Max = a
Else
Max = b
End If
End Function
Sub Event_OnPlay
Dim strRetVal, TrackPath
TrackPath = Escape(CheckPath(SDB.Player.CurrentSong))
TrackPath = Replace(TrackPath,"%5C","%2F")
TrackPath = Replace(TrackPath,"#","%23")
If ManualTrackChange = True Then
' MsgBox("Manual")
Call SendSqueezeBoxCmd("stop")
' MsgBox( TrackPath )
Call SendSqueezeBoxCmd("playlist play file%3A%2F%2F%2F" & TrackPath )
Else
' MsgBox("Auto")
Call SendSqueezeBoxCmd("playlist add file%3A%2F%2F%2F" & TrackPath )
ManualTrackChange = True
End If
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
End Function
Sub Event_OnStop
Call SendSqueezeBoxCmd("stop")
End Sub
Sub Event_OnShutdown
On Error Resume Next
Call SendSqueezeBoxCmd("stop")
CloseSqueezeBox
End Sub
Sub Event_OnPause
If SDB.Player.IsPaused Then
Call SendSqueezeBoxCmd("pause FromMediaMonkeyOn")
Else
Call SendSqueezeBoxCmd("pause FromMediaMonkeyOff")
End If
End Sub
Sub Event_OnSeek
Dim strRetVal, TrackPath
strRetVal = SqueezeBoxMode
TrackPath = Escape(CheckPath(SDB.Player.CurrentSong))
TrackPath = Replace(TrackPath,"%5C","%2F")
If InStr(1,strRetval,"mode stop") > 0 Then
Call SendSqueezeBoxCmd("playlist play file%3A%2F%2F%2F" & TrackPath )
End If
Call SendSqueezeBoxCmd("time " & SDB.Player.PlaybackTime*0.001 )
End Sub
Sub Event_OnTrackEnd
MsgBox("Track End")
ManualTrackChange = False
End Sub
Sub Event_OnPlaybackEnd
MsgBox("Playback End")
ManualTrackChange = False
End Sub
Sub Event_OnIdle
MsgBox("Idle End")
ManualTrackChange = False
End Sub
Function ShortFilePath(LongFilePath)
Dim FSO : Set FSO = CreateObject( "Scripting.FileSystemObject" )
ShortFilePath = FSO.GetFile(LongFilePath).ShortPath
End Function
Function CurrentSong
CurrentSong = ShortFilePath( CheckPath(SDB.Player.CurrentSong) )
CurrentSong = Escape( CurrentSong )
CurrentSong = Replace(CurrentSong,"%5C","%2F")
End Function