full listings » Playback, Tools


GET control gfxmonk

Control songbird via GET requests


Description

Control songbird playback via HTTP (localhost only)

It's not the best idea, but until songbird on OSX works properly with command line arguments, it's the only way of controlling songbird from the command line (and, therefore, with global hotkeys).

Usage:

  • command line
    The easiest thing is to use the included script. On my system, it lives at
    ~/Library/Application Support/Songbird2/Profiles/xxxxxxx.default/extensions/get-control@gfxmonk.net/songbird-ctl

    I suggest making a symlink somewhere on your $PATH, and then you can hook it up to be run for whatever hotkeys you like

  • web interface
    The web control page is part of the github project (it's in the web-control folder). Boosh wrote the original version, and I've modified it to include some information about the current track.

    You'll need to run it from an actual web server (with PHP), and if that's a different computer than the one songbird is running on you'll need to modify the included php script (and set the songbird preference extensions.GET-control.localonly to false).

  • If you want to do things manually:
    load http://localhost:50136/ctl/ACTION with your preferred HTTP client
    - where ACTION is one of: play, pause, playpause, next, prev, stop, mute, volumeup, volumedown

    You can specify the port to use in the preference "extensions.GET-control.port" (requires restart to take effect) If you want to allow any computer on your network to control songbird, set "extensions.GET-control.localonly" to false

The source is on github: http://github.com/gfxmonk/songbird-get-control




Release Notes

Added status information (about the currently playing track).
Added a web interface (created by boosh, with modifications by jhlassen17 and now myself) - it's not part of the extension itself, you can get it from the github project




Comments

(40)


GeekShadow
GeekShadow

Awesome !!!
Thanks a lot for this addon :)

6 months ago
GeekShadow
GeekShadow

Can you made an option to allow access to the network and not only local ?
I know it's "server._socket.init(server.port, false, -1);" You just need to put an option :)

6 months ago
GeekShadow
GeekShadow

Tell me how I can help, You can add me to the github project ;)

6 months ago
boosh
boosh

Just what I wanted! thanks!

6 months ago
boosh
boosh

^^ and allowing access via a network would be perfect ;-)

6 months ago
gfxmonk
gfxmonk

Wow, quick feedback! Glad it's useful.

I can add an option to allow remote connections, maybe this weekend or so.

GeekShadow: You can just "fork" my project and make your own modifications (you'll need git installed on your computer). When you're done, send a "pull request" and I can merge your changes into mine :)

6 months ago
GeekShadow
GeekShadow

@gfxmonk
Sweet :)

6 months ago
GeekShadow
GeekShadow

@gfxmonk
Ok I try things to get my changes commit with GIT, but I don't find how to do that. I find SVN more easy :D
So I have a pretty good solution I will post patchs here (and I wait for you to put the project on a SVN :p)

Patch 1 : http://geekshadow.com/fichiers/patch1_getcontrol.zip
modified files : install.rdf, server.js
Add : volumeup, volumedown, mute, stop

6 months ago
gfxmonk
gfxmonk

Thanks geekshadow :)

Here's a quick tutorial for SVN users learning git:

http://git.or.cz/course/svn.html
Basically for your purposes, once you clone your own github project and make changes, run

git commit -am 'my change description'
git push

(sorry, I have no plans to make an SVN repo).

6 months ago
GeekShadow
GeekShadow

@gfxmonk
Thanks, I know you wont move to svn since you already have many projects on github, I was joking ;) Still I need to learn more about git, thanks for the link !

6 months ago
boosh
boosh

Thanks for the update gfxmonk/geekshadow!!

6 months ago
longbow
longbow

Networked control via the web?! My dreams have come true. Thanks gfxmonk now i can die happy :D

6 months ago
boosh
boosh

hey again, I'm trying to get it to work over the network via a webpage:
http://web.mst.edu/~mjppw9/songbird-control/
But right now it only works on the local computer and not over the network (I have extensions.GET-control.localonly set to false).. Do I have to use the script located in the extension directory directly and not use the http://localhost:50136/ctl/ACTION command. Or Is one of my computers just being stupid... Any help/direction would be greatly appreciated ;-)

6 months ago
gfxmonk
gfxmonk

Hah, cool!

The trouble is you've hooked the buttons up to localhost:50136/ctl/ACTION.

in order for it to work, you'll need to use the actual address of the machine running songbird instead of "localhost". This will probably need to be the machine's IP address.

That means that whoever uses this webpage will need to have access to your machine's 50136 port. Which might well require some firewall configuration.

6 months ago
boosh
boosh

Ha Ya, I was laying in bed and uttered "localhost... oooooh... theres the problem.." rookie mistake! Completely overlooked localhost - I'm using my computers network name now... :-) .. Using the ip address didn't work for some reason, but the computer's network name did! Swweet! Thanks!

6 months ago
GeekShadow
GeekShadow

@boosh
Nice interface !
Can you made it available to other people ? (Zip it and have gfxmonk to put it in description)

6 months ago
GeekShadow
GeekShadow

@boosh
great ! I test it on Fennec : no problem, and Android browser : You can only clic once on a button, you need reload the page to get the button working again.

Also it may be better to move the script in PHP to have only one var for computer url.

6 months ago
boosh
boosh

@GeekShadow
Ya right now the links are opening in a hidden iframe, so if you know how to do it more efficiently using PHP that would be awesome!

6 months ago
boosh
boosh

errr... I found a way to avoid the scripts i'm using... i'll update it soon, and you can test it..

6 months ago
boosh
boosh

ok try this on in android: http://wiki.songbirdnest.com/@api/deki/files/1085/=songbird-control.zip
should be all-browser friendly now, hopefully...

6 months ago
jhlassen17
jhlassen17

Is it possible to poll information from SongBird? Like if I wanted to glance and see what was playing, or would that be beyond the scope of this addon? I would be willing to help code it, what do you guys think?

6 months ago
jhlassen17
jhlassen17

To explain more, I am definitely using this on my phone to control Songbird from anywhere in the house. I think it would be cool to see what was playing from my phone, but I know that would require a bunch of code, and I don't know if other people use it that way. I think this is a great addon as it is, thanks for putting it together.

6 months ago
gfxmonk
gfxmonk

Yeah, it should be possible to add some commands that return status information (actually, it could potentially be returned for every request, depending on how much data there is).

The "server" processing requests is entirely hacked-together, but it should be simple enough to return a JSON object for an XMLHTTPRequest to parse.

boosh: if you want an AJAX version (instead of an iframe), I'd definitely recommend trying jQuery. It makes ajax almost trivial.
The only trouble is that the server would need to also be the computer running songbird - same-origin policies prohibit any AJAX requests to a different domain.

6 months ago
jhlassen17
jhlassen17

@boosh: Hey, if it is okay with you, I edited your UI to use AJAX. I made two versions, one for local use and one for remote use. They are pretty much the same.

The remote one uses PHP to post the GET request, which bypasses the AJAX domain restrictions. Let me know if this is helpful. File Here.

Thanks.

6 months ago
boosh
boosh

@jhlassen17: Ya, no problem! What's mine is yours ;-) They're awesome (I linked to them on the wiki page)

I was also bored and created an iGoogle gadget for people that lack a web site...
http://www.google.com/ig/directory?url=songbird-remote.googlecode.com/svn/trunk/songbirdcontrol.xml

6 months ago
gfxmonk
gfxmonk

Is it cool with you folks if I add the local / remote HTML pages into the git project, to keep it in one place? (or at least in many linked places, via your own forks)
That way we can have proper forking / versions / etc.

6 months ago
jhlassen17
jhlassen17

Yeah, that's fine with me.

6 months ago
bryab
bryab

excellent add-on... only way i could get global hotkeys working on Mac OS w/ Quicksilver (the other command line addon wouldnt work in Mac OS). I can see how this could also be useful for remote control.

6 months ago
uzuuru
uzuuru

This is an excellent add-on, I have now made an Google Chrome extension based on it and boosh's webpage control using XMLHttpRequest, downloadable here.
Well, I wanted to check wheter the current song was playing by using the JSON answer to set the play/pause button correctly, but as it seems there is no answer I could get the information from, any ideas?
You can get the code here or as zip.

4 months ago
gfxmonk
gfxmonk

uzuuru:

You might not be using the latest version of the addon. The current version of the code returns a useful struct when you send it the "status" command. Looking at firebug, when I use the latest version of the web remote ( http://github.com/gfxmonk/songbird-get-control in the web-control folder ), I see the following request being made:

URL: http://localhost/~tim/sb/control.php?ctlEvent=status
RESPONSE: {"playing":true,"artist":"Wolf Parade","album":"Apologies To The Queen Mary","track":"I'll Believe In Anything","version":"0.3"}

here "playing" seems to be what you're after.

4 months ago
uzuuru
uzuuru

You are right, I knew this before and was also using the latest version, I've also tried to connect with a simlpe Java application I want to use to implement a system-wide now playing key shortcut, however with Java it works perfectly but the JavaScript XMLHttpRequest object doesn't return any text at all, the responseText is empty and the responseBody is undefined after my send() call.
See the source of my toolstrip here, maybe you can tell me what I'm doing wrong?

4 months ago
gfxmonk
gfxmonk

The reason it's not working for me is because your site is not allowed to make ajax requests to a different domain (localhost). I don't know if you'd have the same issue when you run it yourself locally (it may still consider a different port number to be a different "origin").

Can you try routing your ajax requests through the control.php that jhlassen17 wrote? (this is how it's done in the remote from my github repository)

(btw it's javascript, not java)

4 months ago
uzuuru
uzuuru

I see I confused you a bit, what I meant was:
In my Chrome extension, I want to use a XMLHttpRequest to retrieve the status and/or send the clicked commands. I have allowed the access to any hosts via HTTP in the config file of the extension.
However it doesn't work like I wish, get control would take the command and execute it but there is no response data when onreadystatechanged is called and readyState is 4.
I also wrote a little Java application that sent the status command and I could receive an answer with it.

4 months ago
uzuuru
uzuuru

If I understand correctly all this php file does is taking requests on port 80 and forwarding them to the GET command port, right? I would have to set up an web server on port 80 to use this php file, right?

4 months ago
gfxmonk
gfxmonk

Yep, using the PHP would require a server (it doesn't have to be on port 80, but most are). And yes, it's just a proxy to get around security rules.

Ahh. I thought what could be happening is the cross-domain security rules were preventing your ajax calls from working. If songbird is getting the call, then that must not be the case. I'm afraid I don't know what else the problem could be. It might be worth comparing your code to the remote in my repository, since that's known to work (you can run it without requiring the php proxy)

4 months ago
uzuuru
uzuuru

I have tried numerous ways now to get this working, but no one seems to be able to break through the security walls...
An XMLHttpRequest would get as far as sending a request and maybe even getting a response, but if cross-orgin is the case, then the response will not be readable, that's e.g. the concept of some does-that-host-exist-check script, it opens the pages using a XHR too, but doesn't use the contents.
What I've tried too was using a Java applet and direct Socket calls, but that failed too because applets aren't allowed to cross-orgin-request data either.
When I tried to use your remote too, but shouldn't it output something about the track? For me, it didn't output anything...
Of course I've tried to use the php relay too, but unfortunately I couldn't get that WAMP server running so that it would process the curl calls...
Well, I've got to go to school tomorrow, so maybe it's better if I stop wondering about it for now, good night from Austria.

4 months ago
Elcado
Elcado

Please, please... update for 1.4.3...

2 months ago
gfxmonk
gfxmonk

I'm afraid that if it doesn't work by modifying the version compatibility strings, there's nothing I can do. songbird corrupted my database for the second time, and now I can't even start it. I'm using rhythmbox until that kind of thing stops happening.

about 1 month ago



Log in to Post a Comment


Download
Statistics
Downloads: 785

Average Rating:
4 out of 5  based on 5 ratings

Images: 0

Comments: 40

Last Updated: 6 months ago
Details
Name: GET control

Author: gfxmonk

Contributors: Antoine Turmel (GeekShadow)

Version: 0.3 version history

Categories:


Log in to Add a Tag
Share
Embed:

Share: