Page 3 of 4
Posted: Wed Feb 27, 2008 3:30 pm
by trixmoto
As far as I can see all you need to do is put...
Code: Select all
str = "file://"&Replace(str,"\","/")
...as the first line in the "fixurl" function. Obviously "str" is the url parameter passed in, I'm not sure what it is in this script.
Posted: Wed Feb 27, 2008 4:30 pm
by BuckNaked
Thanks for your answer.. not being a programmer, this is as far as I understand the part that needs to be modified:
Code: Select all
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 file:///" & TrackPath )
Else
Call SendSqueezeBoxCmd("playlist add file:///" & TrackPath )
End If
Ie by inserting "your" string after the TrackPath is retrieved.. maybe like this:
Code: Select all
Dim strRetVal, strModeQry, TrackPath
strModeQry = "mode ?"
SqueezeBoxSocket.SendLine strModeQry
strRetVal = SqueezeBoxSocket.GetLine
'MsgBox strRetVal
TrackPath = Escape(CheckPath(SDB.Player.CurrentSong))
TrackPath = Replace(TrackPath,"\","/")
If InStr(1,strRetval,"mode stop") > 0 Then
Call SendSqueezeBoxCmd("playlist play file://" & TrackPath )
Else
Call SendSqueezeBoxCmd("playlist add file://" & TrackPath )
End If
However this doesn't change anything as far as I can see from the Squeezebox debug output, so I guess something more is needed.. I'll keep trying but if someone else can help me figure out the replace string needed to go from
D:\- Musik\Niobe.mp3 being sent as D%3A%5C-%20Musik%5CNiobe.mp3
to being sent as file%3A%2F%2F%2FD%3A%2F-%2520musik%2Fniobe.mp3 I think the problem will be solved..
Oh, another strange thing: It doesn't seem as the "file.." part ever gets passed on to the SB CLI.. But I have no idea where/how it gets stripped, maybe it's the w3 sockets-thingie..? Like I've mentioned, I'm no programmer.

Posted: Wed Feb 27, 2008 6:12 pm
by trixmoto
Actually in this case the characters have already been converted, so you'll need to do the replace on the converted characters. Also you're still passing in "file://" without encoding. Try something like this...
Code: Select all
Dim strRetVal, strModeQry, TrackPath
strModeQry = "mode ?"
SqueezeBoxSocket.SendLine strModeQry
strRetVal = SqueezeBoxSocket.GetLine
'MsgBox strRetVal
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 )
Else
Call SendSqueezeBoxCmd("playlist add file%3A%2F%2F%2F" & TrackPath )
End If
Posted: Thu Feb 28, 2008 10:36 am
by Nonreality
I feel kinda stupid here but how do I use this script? I have a Squeezebox 3 and MM (finally bought just now but have been using for a couple of months) and this would be great! Do I copy one of the above scripts and paste it into a txt file then rename it? Is it for MM or squeezecenter? Any help would be great. Btw the squeezebox is one of the best things you can get yourself if you have a stereo and music on a computer.
Fantastic!
Posted: Thu Feb 28, 2008 11:56 am
by BuckNaked
Thanks a million
trixmoto, with your help I've finally got it to work!
Nonreality: Well yeah, sorta.. I must say that this script works far from perfectly so far (I will try to outline a few problems later tonight), but in this form at least it can now pass files to SlimServer to play (some problems include no next/previous song, some problems with timing and play/pause.. I'll try to expand on this later tonight as mentioned).
The script in this form works for me with MM3 and SB3 (Slimserver running on Windows XP).
1) Save as a text-file, rename it to something.vbs (ie squeezebox.vbs or whatever) and place it in \MediaMonkey\Scripts\Auto
2) Make sure you download and install w3sockets as mentioned in the beginning of the script comments (and also earlier in this thread)
Ok, here we go:
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
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)
SqueezeBoxSocket.SendLine strPlayerCmd
End Sub
Sub Event_OnPlay
'
Dim strRetVal, strModeQry, TrackPath
strModeQry = "mode ?"
SqueezeBoxSocket.SendLine strModeQry
strRetVal = SqueezeBoxSocket.GetLine
'MsgBox strRetVal
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 )
Else
Call SendSqueezeBoxCmd("playlist add file%3A%2F%2F%2F" & 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 return 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
Cheers,
Buck
Posted: Fri Feb 29, 2008 2:03 am
by Nonreality
Thank you. I don't have time tonight but I'll set it all up and play with it. It would be handy when I'm on the computer and want to set up playlists and listen to music. Most of the time the regular squeeze box player is great. Does this actually decode the music in MM and then send it or just send the song names and then the squeezebox decodes? I'm figuring the latter. Again thanks!

Posted: Fri Feb 29, 2008 4:07 am
by trixmoto
Glad I could help!

Posted: Sat Mar 01, 2008 6:01 am
by BuckNaked
Nonreality: Yeah, you are correct, it passes the file name/path to SlimServer. I also recommend checking out Moose
http://www.rusticrhino.com/drlovegrove/ which is specifically built to be a GUI for SlimServer and works pretty good (ie it communicates both ways meaning you can pause using the remote and Moose will pause, it will read the playlist from Slimserver and so on), though it has a few weaknesses. In a perfect world MM and Moose would combine..

Posted: Sun Mar 16, 2008 2:31 pm
by Nonreality
Thanks for info on Moose. It works pretty good and is very cool.
Posted: Fri Apr 25, 2008 12:02 am
by revel
WOW!
I know my original script was quick and dirty and didn't work that well, but you guys are hooking it up! Great to see it sparked some interest.
Sorry for not working on it anymore though, I got an xbox 360 and that changed my situation so I didn't really need this anymore.
Todd/revel
Re: MM and SqueezeBox Script
Posted: Thu Aug 07, 2008 12:48 pm
by DC
For everyone who wants to make their MM data available for Squeezeboxes etc, please see also
http://www.mediamonkey.com/forum/viewto ... =2&t=31680. I made a script which exports MM data into an iTunes library.xml. The xml can be read by the SqueezeCenter iTunes plugin and maybe also by other programs.
Re: MM and SqueezeBox Script
Posted: Fri Sep 12, 2008 6:29 pm
by daverb70
Has anyone got this working on Vista? When I try and install wSockets I get an error:
Call to DllRegisterServer failed in "C:\Users\User\Desktop\socket.dll"
It would be great to control Squeezebox from MM!
Re: MM and SqueezeBox Script
Posted: Thu Sep 18, 2008 9:24 am
by ndelectro
Hi,
I tried to use the script. I get the following error message
Error #-2147418113 - Socket.TCP
Error while processing Socket opperation: Can't assign requested address
File: "C:\Programme\MediaMonkey\Scripts\Auto\slimserver.vbs",Line: 66, Column: 6
I use squeezcenter 7.2 and I installed also w3sockets
Has somebody an idea
Thanks + Best Regards
Norman
Re: Please explain
Posted: Thu Oct 23, 2008 2:50 pm
by OyvindO
Hope you have more luck with this. Remember I had to use the full ip address for my slimserver rather than localhost. Perhaps you will have to also.
The script still has an issue with timeouts every so often. I hope to investigate that shortly.
Good Luck

[/quote]
Please explain what this script is supposed to do?
I may be stupid, but I have totally failed to understand what it does. What to expect?
Does it play my MP3's through my SqueezeBox ?
Does it create an XML file which I can import into SqueezeCenter ?
I have successfully installed the script and the Socket dll, and MM3 starts now without any errormessages, but so what?
I fail to understand what to do next, or what to expect, or where to look for what?
Can you help, since your wrote the script - you must know what it does?
Many thanks for yout help.
Rgds
OyvindO from Norway

Re: MM and SqueezeBox Script
Posted: Sun Mar 01, 2009 3:50 pm
by debacle
Oyvindo, the point of the script is that whenever MediaMonkey plays a song, it will tell SqueezeCenter to play that same song (by giving it the file path).
Also, when you press Pause or Stop in MediaMonkey, it will tell SqueezeCenter to Pause or Stop.
I've added an OnSeek handler to my script:
Code: Select all
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