Posted: Sun Jan 13, 2008 11:48 am
Will see If I could get time to make Setup Sheet for Changing IP Under Player Setup and make things easier. It Should Be easy to make.
Edit: Here it is I have Added Setup Sheet "SqueezeBox Controller" and made Changes so that MM sends Cached path instead of Source Path to support MM VirtualCD feature for caching offline tracks.
What To say except enjoy
Edit: Here it is I have Added Setup Sheet "SqueezeBox Controller" and made Changes so that MM sends Cached path instead of Source Path to support MM VirtualCD feature for caching offline tracks.
Code: Select all
'==========================================================================
' NAME: SqueezeBox Controller
'
' ORIGINAL AUTHOR: Todd Nemeth /revel
' DATE STARTED: 26.09.2007
'
' ADDITIONAL AUTHORS: Baz, Big_Berny, Peke
' UPDATE DATE: 13.01.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
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,"OnShutdown","Event_OnShutdown")
ind = SDB.UI.AddOptionSheet("SqueezeBox Controller",Script.ScriptPath,"InitSheet","SaveSheet",-2)
InitSqueezeBox
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
Set SqueezeBoxSocket = CreateObject("Socket.TCP")
SqueezeBoxSocket.DoTelnetEmulation = True
SqueezeBoxSocket.TelnetEmulation = "TTY"
SqueezeBoxSocket.Host = SDB.IniFile.StringValue("SqueezeBox","IP") & ":9090"
SqueezeBoxSocket.Open
End Sub
Sub CloseSqueezeBox
SqueezeBoxSocket.Close
End Sub
Sub SendSqueezeBoxCmd(strPlayerCmd)
' MsgBox strPlayerCmd
SqueezeBoxSocket.SendLine strPlayerCmd
End Sub
Sub Event_OnPlay
'
'Check State of Slimserver playlist if mode is stoped then use playlist play
'otherwise use playlist add
'
Dim strRetVal, strModeQry, TrackPath
strModeQry = "mode ?"
SqueezeBoxSocket.SendLine strModeQry
strRetVal = SqueezeBoxSocket.GetLine
'MsgBox strRetVal
TrackPath = Escape(CheckPath(SDB.Player.CurrentSong))
If InStr(1,strRetval,"mode stop") > 0 Then
Call SendSqueezeBoxCmd("playlist play " & TrackPath )
Else
Call SendSqueezeBoxCmd("playlist add " & TrackPath )
End If
'
'need to retrieve retuned line from the last play so that next time I check the mode I dont retrieve it
'in stead of the mode returrn line
'
strRetVal = SqueezeBoxSocket.GetLine
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
Call SendSqueezeBoxCmd("stop")
CloseSqueezeBox
End Sub
Sub Event_OnPause
Call SendSqueezeBoxCmd("pause")
End Sub