MM and SqueezeBox Script

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

Peke
Posts: 17493
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

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.

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
What To say except enjoy
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
steve_c
Posts: 39
Joined: Fri Jan 11, 2008 9:06 am
Location: SE Norway

Post by steve_c »

I'd like to add a "me too". I'd love to be able to control a slimserver somehow in conjunction with MM3. I just started a separate thread in Help asking if it was possible to somehow export playlists from PC-MM3 that unix-flavoor slimserver can understand, but I like the idea of this thread a lot!
Peke
Posts: 17493
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Thx, this community is one of best I have been part from 1992->Today

Off topic: If you get us Example Of Playlist on Linux I doubt that it will be too hard to make it ;)
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
wolfzell
Posts: 155
Joined: Fri Apr 23, 2004 8:42 am
Location: Germany

Post by wolfzell »

Before I will give this a try, please tell me: Will this work too, if Slimserver is installed on another machine than the one running MediaMonkey?

My Mediaserver is installed somewhere where I won't hear the noise of it, but still it would be good to control the Squeezebox from the PCs around the house...

bye
Wolfgang
Peke
Posts: 17493
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

I do not own device myself but as Noted I can provide any help/support in my power to see it work (As noted from my changes), even actual testings must be done by users owning device.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
runtherisk
Posts: 75
Joined: Sun Mar 05, 2006 3:05 pm
Location: PA, USA

Post by runtherisk »

Would the development of this script work with the squeezebox duet??
http://www.slimdevices.com/pi_duet.html I currently have a stand alone Audio Request server and would seriously consider switching if I can stream via MM. Any pre-purchase info would be appreciated.
steve_c
Posts: 39
Joined: Fri Jan 11, 2008 9:06 am
Location: SE Norway

Post by steve_c »

If the script works with other SBs then it will work with a Duet, because the Duet will be driven by the same slimserver sending the music to it, it's just that the Duet receiver will not have its own visual interface - that is moved to the new Controller (which will also work with other SBs).

(SB1, SB2, SB3, Transporter, Synology NAS user)

Edit: I guess one way to test is to install the Squeezebox emulator called Softsqueeze and test what you can do. http://softsqueeze.sourceforge.net/
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

Post by BuckNaked »

Edit: This problem has been fixed..

The version posted by Peke unfortunately doesn't work for me, as I get the following error during startup:

Error #-2147024770 - (Line 62), which contains the line
" Set SqueezeBoxSocket = CreateObject("Socket.TCP")"

and then also this error:

The specified module could not be found

I think I've tracked it to be something concerning ActiveX, but I have no idea how to fix it.. Any ideas?

Thanks in advance, I'd really love to be able to use this.
Last edited by BuckNaked on Fri Feb 01, 2008 2:47 pm, edited 1 time in total.
Baz
Posts: 8
Joined: Mon Mar 12, 2007 9:16 am
Location: Southampton U.K.

Thoughts On Further Development

Post by Baz »

Hi,
I've been using this little script (Peke's latest version) daily for 2-3 hour stretches since the last updates and have been mostly pleased with it. However currently the script isn't stable enough to to just set MM playing with auto-dj turned on and walk away, due to the following problems :-
  • The playlist on MM after a while tends to end up a song or two ahead of the playback on my squeezebox and can become more extreme if the squeezbox is going through one of its freezing and rebuffering cycles.
  • I have also noted the occasional time out reported which generally ends up with the squeezebox playback stopped. With a little manual tidying up on both the squeezebox and MM players this can be recovered and normal play resumed.
An unforseen issue with the way the script handles MM's events is that, if, whilst a track is playing you use 'Play Now' to immediately stop the current playback and Play your selected Track/Album/Playlist, the currently playing track on your squeezebox will be stopped, the first track in your new selection added to the squeezeboxes playlist, and .... nothing :-? . The sqeezebox is left stopped on the track it was playing with a new track cued up after it and MM is merilly playing on.

So if any of you know how to determine that a 'Play Now' event has happened so that it can be correctly handled some guidance would be appreciated :) .

Another thought on an improvement to the script is the ability to turn it off within MM so that if you wish to play music back via MM on your PC without using your squeezebox once in a while you can. Again guidance, examples or offers to implement it would be appreciated :D .

I think thats plenty to be looking into for now. So far tonight MM and SqueezeServer are playing together nicely. 24 tracks and counting.

Cheers
Barry Goddard

Image
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

Post by BuckNaked »

Argh, I just solved the first problem by reinstalling w3sockets.. sorry for the stupid mistake.

However, now I have another problem.. I can't get my SB to play the MM files - when I click play in MM, the path to the music file is shown on the squeezebox, but then nothing happends (oh, the SB playlist is cleared too btw, and nothing is added).
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

Post by BuckNaked »

Anyone..?

Not being able to use this makes me a very sad monkey. :(
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

Post by BuckNaked »

Sorry for multiple posts, but here is a debug log from Slimserver (7.0b):

Code: Select all

-10 22:09:35.2377] Slim::Plugin::CLI::Plugin::cli_socket_accept (239) Accepted connection from 192.168.1.6:3645 (1 active connections)
[08-02-10 22:10:07.8747] Slim::Plugin::CLI::Plugin::cli_process (558) Request [mode] requires client, allocated 00:04:20:12:57:07
[08-02-10 22:10:07.8750] Slim::Plugin::CLI::Plugin::cli_process (568) Processing request [mode]
[08-02-10 22:10:07.8753] Slim::Plugin::CLI::Plugin::cli_process (602) Dispatching [mode]
[08-02-10 22:10:07.8758] Slim::Control::Request::dump (2207) Request: Query [00:04:20:12:57:07->mode] from CLI  (Dispatchable)
[08-02-10 22:10:07.8771] Slim::Plugin::CLI::Plugin::client_socket_write (437) 192.168.1.6:3645 - Sending response [00%3A04%3A20%3A12%3A57%3A07 mode stop...]
[08-02-10 22:10:07.8777] Slim::Plugin::CLI::Plugin::client_socket_write (463) Sent response to 192.168.1.6:3645
[08-02-10 22:10:07.8795] Slim::Plugin::CLI::Plugin::cli_process (558) Request [playlist] requires client, allocated 00:04:20:12:57:07
[08-02-10 22:10:07.8798] Slim::Plugin::CLI::Plugin::cli_process (568) Processing request [playlist]
[08-02-10 22:10:07.8801] Slim::Plugin::CLI::Plugin::cli_process (602) Dispatching [playlist]
[08-02-10 22:10:07.8805] Slim::Control::Request::dump (2207) Request: Command [00:04:20:12:57:07->playlist play] from CLI  (Dispatchable)
[08-02-10 22:10:07.8808] Slim::Control::Request::dump (2211)    Param: [_item] = [D:\test.mp3]
[08-02-10 22:10:07.8813] Slim::Control::Commands::playlistXitemCommand (1038) cmd : play
[08-02-10 22:10:07.8816] Slim::Control::Commands::playlistXitemCommand (1039) item: D:\test.mp3
[b][08-02-10 22:10:07.8819] Slim::Control::Commands::playlistXitemCommand (1064) url: D:\test.mp3
[08-02-10 22:10:07.8824] Slim::Control::Commands::playlistXitemCommand (1106) path: D:\test.mp3
[08-02-10 22:10:07.8837] Slim::Control::Commands::playlistXitemCommand (1115) currentPlaylist:file:///D:/test.mp3
[08-02-10 22:10:07.8841] Slim::Control::Commands::playlistXitemCommand (1151) jumpToIndex: 0
[08-02-10 22:10:07.8938] Slim::Control::Request::notifyFromArray (774) (playlist cant_open D:\test.mp3 PLAYLIST_EMPTY)[/b]
[08-02-10 22:10:07.8962] Slim::Control::Request::notifyFromArray (774) (playlist load_done)
[08-02-10 22:10:07.8968] Slim::Control::Request::callback (1872) Callback disabled
[08-02-10 22:10:07.9052] Slim::Control::Request::notifyFromArray (774) (prefset server currentSong )
[08-02-10 22:10:07.9378] Slim::Plugin::CLI::Plugin::client_socket_write (437) 192.168.1.6:3645 - Sending response [00%3A04%3A20%3A12%3A57%3A07 playlist play D%3A%5Ctest.mp3...]
[08-02-10 22:10:07.9621] Slim::Plugin::CLI::Plugin::client_socket_write (463) Sent response to 192.168.1.6:3645
[08-02-10 22:10:07.9735] Slim::Control::Request::notifyFromArray (774) (prefset server currentSong )
[08-02-10 22:10:14.2251] Slim::Plugin::CLI::Plugin::cli_process (558) Request [pause] requires client, allocated 00:04:20:12:57:07
[08-02-10 22:10:14.2264] Slim::Plugin::CLI::Plugin::cli_process (568) Processing request [pause]
[08-02-10 22:10:14.2272] Slim::Plugin::CLI::Plugin::cli_process (602) Dispatching [pause]
[08-02-10 22:10:14.2283] Slim::Control::Request::dump (2207) Request: Command [00:04:20:12:57:07->pause] from CLI  (Dispatchable)
[08-02-10 22:10:14.2302] Slim::Control::Request::dump (2207) Request: Command [00:04:20:12:57:07->playlist jump] (Dispatchable)
[08-02-10 22:10:14.2311] Slim::Control::Request::dump (2211)    Param: [_index] = [0]
[08-02-10 22:10:14.2376] Slim::Plugin::CLI::Plugin::client_socket_write (437) 192.168.1.6:3645 - Sending response [00%3A04%3A20%3A12%3A57%3A07 pause...]
[08-02-10 22:10:14.2386] Slim::Plugin::CLI::Plugin::client_socket_write (463) Sent response to 192.168.1.6:3645
[08-02-10 22:10:14.2411] Slim::Control::Request::notifyFromArray (774) (prefset server currentSong )
I have no idea why the response is playlist empty and so on.. maybe someone who knows the CLI interface can help out?
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

Post by BuckNaked »

After some more debugging, I can get SlimServer to queue or play a file (d:\- musik\niobe.mp3) by telnetting to the server and sending the following

Code: Select all

playlist add file%3A%2F%2F%2FD%3A%2F-%2520musik%2Fniobe.mp3
however, when trying to play the same file via MM, this is sent:

Code: Select all

playlist add D%3A%5C-%20Musik%5CNiobe.mp3
Not being a programmer, I have no idea how to change the MM VBS behaviour to send the above command format instead.. I'm hoping someone else might be up to the task?

Cheers, BN
Baz
Posts: 8
Joined: Mon Mar 12, 2007 9:16 am
Location: Southampton U.K.

Post by Baz »

Hi Buck (and any other interested parties),

I decoded the url encoded command that BuckNaked proved works and found that the main difference from the one the script would have generated is the addition of file:/// to the front of the filename before it is encoded.

A collegue of mine tells me thate file:/// is a reference to the local file service.

I have changed the following code to take this into account and have tested it using MM 3 SqueezeCenter 7.0 and Softsqueeze 3.0, which now works for me where it did not before.

I have not yet tested it on my usual setup of MM3 SlimServer 6.5.4 and my Squeezebox yet but will do so later in the day.

Code: Select all

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 file:///" & TrackPath ) 
  Else 
    Call SendSqueezeBoxCmd("playlist add file:///" & 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
I have no idea why this is nescessary for SqueezeCenter 7.0 and not SlimServer 6.5.4.

Hope It works for you too :P
Barry Goddard

Image
BuckNaked
Posts: 23
Joined: Fri Aug 11, 2006 4:13 pm

Post by BuckNaked »

Getting closer.. :) But still no luck for me using SS7.0 and a SB3.. however, Peke sent me a PM that it could be possible with corrections to the URLENCODE function made by Trixmoto..

Here is all info needed:

Original Path: D:\- Musik\Niobe.mp3

Current Encode filename Name: D%3A%5C-%20Musik%5CNiobe.mp3

The one My SqueezeBox needs is full UrlEncoded Using Explorer URL for Local Filename file%3A%2F%2F%2FD%3A%2F-%2520musik%2Fniobe.mp3 (or file://D:/-
Musik/Niobe.mp3 un-encoded)


Can someone make needed changes?

Big thanks to both of you (Baz, Peke) for your help on this. I'll be off skiing for a week now so won't be able to check back for a while.. See ya when I return :)
Post Reply