Ever since I switched from iTunes to using web-based music players (Google Music, Amazon Cloud Player, and Pandora), I’ve wanted the ability to control them with global keyboard shortcuts. The other day, I finally took the time to set it up, and I’m very happy with the results:
If you’re interested in setting this up for yourself (or simply learning about how it works), download the project files here, then follow these instructions:
- Unzip the project files. You should see a directory called “music_control”.
- Make sure you have node.js installed, then cd into the “music_control” directory and start the server with:
- Cd into the “extension” directory and open “background.html” in your favorite editor. Change the
SERVER_HOSTvariable to reflect your host name.
- In Chrome, go to Window > Extensions. Make sure “Developer Mode” is checked.
- Click on “Load unpacked extension,” then navigate to the “extension” directory. (You can also package the extension and install it normally by double-clicking on the resulting “music_control.crx” file.)
- Install any application that lets you map global keyboard shortcuts to shell scripts (or AppleScripts, but I prefer bash). I used an app called Shortcuts, but I’m sure there are plenty of free alternatives.
- Setup whatever keyboard shortcuts you want to map to the following bash commands (note that you can use something like
curlif you prefer):
- You’re done! You should now be able to control you web-based music players with keyboard shortcuts.
I realize there are a lot of moving parts here, and any number of ways to accomplish the same thing. If you decide you don’t want to use this exact implementation, hopefully this will at least get you started down the right path of your own setup. Let me know if you get this working and/or if you adapt the concept to something equally or even more interesting. I have lots of ideas for where this could go.
I’ve been tempted to set this up with Autohotkey for a while, but just haven’t bothered yet. Of course, sadly, autohotkey is windows-only.
I’m looking to implement a similar feature for a web app I’m building.
Have you made any more progress or have any recommendations how I would implement this so it would work for my users and my custom player?
Would this be easier if I was running this completely custom just for 1 web app and running my own node server on ec2?
Thanks again for the work and open sourcing this!
Running node on an instance of EC2 is definitely a good start, but you still have to have a method of capturing keystrokes which means running a local native application. Have you figured that part out yet?
I’d like to control Pandora on my Dev box from my iPhone. I do that with iTunes and Remote when I’m on my server in the room next door, for example. A small app for the phone would do the job. I may give it a go.
Nice one. The Chrome extension seems to have a problem installing these days. Think it may just need some changes to the manifest to update it to version 2. Going to take a look.
If you want to try a version with Chrome extensions and apps only
This work is base on yours.
Thanks for your source files Christian Cantrell