James Fator

Hacking my Bluetooth headset

22 August 2014

I picked up a Bluetooth headset last spring but was disappointed when I realized I can't play/pause my Google Music app with the media buttons on the device. Even when iTunes isn't open, when I press the play button on the side, you would expect it to act like the play button on the keyboard, yet it goes ahead and launches iTunes instead.

After spending some time researching the solution on the internet, I saw that most people had complex work-arounds that sometimes even involved deleting the iTunes application entirely, which I didn't really care for so I took a look at it myself.

I researched a few ways of solving this and ultimately came up with the idea of creating a plug-in for the AVRCPAgent which is responsible for the AVRCP (Audio/Video Remote Control Profile) Bluetooth interface to the headset.

By running: otool -o /System/Library/CoreServices/AVRCPAgent.app/Contents/MacOS/AVRCPAgent we're able to get a list of methods that are involved with the AVRCPAgent. I found out that we can hijack the method named handleIncomingAVRCommand and replace it with a custom handler which is called whenever the headset's buttons are triggered.

I was able to write a handler that made basic calls to the existing media keys which gives a much more intuitive experience with the headset. It allows you to play/pause and skip tracks just like you would with the standard keyboard which makes so much more sense than forcing iTunes. The source and instructions to build and install the plug-in can be accessed on GitHub here.

Since I see there is an apparent need for this hack, the current plan is to continue work on it in order to get it up and running for more people to take advantage of. There are still some things that need to be looked at such as ensuring different types of headsets work as well as finding a solution for OS X Yosemite. In the mean time, if you're interested in helping out test/develop this - take a look at the GitHub project and feel free to contact me if you have any questions, comments, or concerns.