beaTunes News

Thursday, August 17, 2017

Remote Control

I've recently mentioned that starting with beaTunes 5.0.3 there is a mechanism that allows limited remote control of beaTunes from another process. This mechanism is pretty straight forward:

  1. Start beaTunes
  2. Locate the beaTunes5rc executable
  3. Run beaTunes5rc SOME.ACTION.ID

Let's assume you're on macOS and have installed beaTunes in the regular /Applications folder. Then beaTunes5rc is located at /Applications/beaTunes5.app/Contents/MacOS/beaTunes5rc (on Windows, a similar executable is located in the installation directory). A handy action id to use is audioplayer.pause.play. So to toggle play/pause from another program or the commandline/terminal, simply execute:

/Applications/beaTunes5.app/Contents/MacOS/beaTunes5rc audioplayer.pause.play

As return value you'll usually get a JSON document similar to this one:

{"request":"audioplayer.pause.play","status":"ok"}

In beaTunes most UI actions have an id and therefore can be triggered via this mechanism. A couple of these ids are listed in the API for RemoteControlService. However, the best way to find valid ids is to ask beaTunes5rc itself. To do so, simply call:

/Applications/beaTunes5.app/Contents/MacOS/beaTunes5rc list

This will return a JSON-formatted list of valid ids, often along with short descriptions.

Additionally to a simple status message some actions may return useful information. To get information about the currently playing song, you can e.g. use audioplayer.track.

The mechanism can be used integrate beaTunes with 3rd party applications, like BeardedSpice. And if you'd like to see a beaTunes integration with BeardedSpice, feel free to upvote the corresponding pull request.

Labels: , ,

0 Comments:

Post a Comment

<< Home