Author Topic: Remote controlled MusicBee  (Read 15557 times)

Elberet

  • Full Member
  • ***
  • Posts: 167
Err, sorry, no. Actually, according to WireShark, it closes the connection immediately after the first TCP packet was received.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
thats a misunderstanding i had with what should be done with a sockets - it keeps the listener open but closes the stocket after the each command is processed.
i'll put in another loop and only close the socket when MB shuts down or the client disconnects
Last Edit: June 29, 2010, 06:40:41 AM by Steven

Elberet

  • Full Member
  • ***
  • Posts: 167
Hm, that sounds like a lot of loops to me, tbh. ;)

My experience shows that I generally need two loops to drive all my sockets in a single thread. The basic premise is to set all sockets to blocking read mode, put them in a list and use select on that list. Select is a blocking call that returns as soon as any socket in the list becomes changes state (e.g. becomes non-blocking readable because the OS has received data on the socket); so you put one loop around select and a second nested loop works the sockets select found to be active. The tricky thing is to get the data structures right so you can figure out which client connection object/instance belongs to which socket, the rest a piece of cake.

Under .NET, you can use System.Net.Sockets.Select.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
hopefully its right this time!
http://www.mediafire.com/?fwkjyzjooty

edit:
also i've added a button in the main preferences window to enter accepted IP addresses (you dont need to enter 127.0.0.1)
Last Edit: June 29, 2010, 10:52:22 PM by Steven

john6555

  • Guest
Sorry to butt in, but how is this useful for the humans among us? ;)

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
its probably more for techies but i'm hoping someone will use the interface to write some plugins for external tools over time
Last Edit: June 30, 2010, 06:45:49 AM by Steven

Elberet

  • Full Member
  • ***
  • Posts: 167
hopefully its right this time!
I'm afraid, not so much. :(

When you bind a socket to an address, the networking stack will only let you see connections the bound address can talk to. If you bind it to 127.*, you'll never see connections from 192.168.* because the subnets do not match. The "state of the art" solution I learned is to just have multiple listen sockets - one for each port and interface.

Anyway, it's really a good thing that the socket is bound to 127.0.0.1; everything else would be way too dangerous and you'd just have to worry about security - and that's a whole different bag of saber-tooth tigers. Just bind to loopback by default, and when a user selects to let MB listen on any other address (via a simple checkbox), they should be told that that's an experimental feature, in no way safe and only meant for people who know what they're doing. Your other option is to basically blow this thing out of proportion and make it safe enough that nothing bad is going to happen even if MusicBee's control port is exposed to the internet (read: chinese hackers)... ;)

Elberet

  • Full Member
  • ***
  • Posts: 167
its probably more for techies but i'm hoping someone will use the interface to write some plugins for external tools over time
http://getmusicbee.com/forum/index.php?topic=1463.0
Like this? ;)

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
i've already changed it since that version so if no additional ip addresses are specified in the preferences it only listens on local host, and if any ip addresses are specificed it listens on any address, but the first thing it does after a connection is check the remote ip address is one of the allowed ip addresses set in the preferences.
But you didnt say whether it worked or not
Last Edit: July 02, 2010, 09:14:55 PM by Steven

Elberet

  • Full Member
  • ***
  • Posts: 167
Er, oops. :)

Yes, the little test script now works just fine. Sending PlayPause twice without delay while MB is playing still results in the weird state where MB thinks it's playing but really isn't.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
i havent looked at the play/pause thing but i know what the problem is (its because there is a small delay to fade the pause and you must be sending the message while its in the in-between state)
But this now has the IP address blocking working as i described above

http://www.mediafire.com/?zzy4ewtk4zd

Elberet

  • Full Member
  • ***
  • Posts: 167
Quote from: Steven
(its because there is a small delay to fade the pause and you must be sending the message while its in the in-between state)
That sounds exactly right. :)

And yep, peer IP matching seems to work ok.
Last Edit: July 05, 2010, 10:59:35 PM by Elberet

pndragon

  • Guest
I'm jumping in to this thread because it seems like the most appropriate one for what my request is.

its probably more for techies but i'm hoping someone will use the interface to write some plugins for external tools over time
http://getmusicbee.com/forum/index.php?topic=1463.0
Like this? ;)

While the above idea is also great, I would propose another step further and say that for me, the ideal remote control will be my iPhone. I would love it if I could get the same feature requests as the aforementioned "HTPC - Now Playing view" request, but also add player and volume controls. Right now I am using an RDP app on my iPhone and while that works, a full fledged iPhone app would be the most preferred choice.