Under The Microscope

Developer Note: Integrating with Airfoil for Windows

For some time now, Airfoil has offered an enhanced experience when transmitting audio from supported audio sources. That enhanced experience meant that Airfoil pulled in metadata like song titles, artist names, and album artwork, then passed it back out to Airfoil Speakers and other AirPlay devices that support it.

Metadata in Airfoil Speakers
Metadata in Airfoil Speakers

It also allowed remote control of the supported audio sources, meaning playback in the audio source could be affected remotely from across the network. When a supported application is transmitted by Airfoil, buttons for play, previous track, and next track will be shown in Airfoil Speakers and Airfoil Remote. Any other AirPlay device that offers controls will be able to remotely control playback as well.

Playback Controls in Airfoil Speakers
Remote control buttons in Airfoil Speakers

However, while the Mac side has offered support for over a dozen audio sources, until now only iTunes was supported on the Windows side.

Version 3.6 of Airfoil for Windows brought two big improvements in this arena. First, we’ve added support for Spotify, our most frequently requested source. Second, and more importantly for developers, we’ve released an SDK to help the makers of audio applications better integrate with Airfoil. If you make any kind of media playing application for Windows, this post is for you. With just a few minutes of work, you can get your application to integrate with Airfoil for Windows and Airfoil Speakers, so your users can see what’s playing and control playback as well.

How It Works

Just like with Airfoil for Mac, we’ve created an easy way for developers of Windows audio applications to be able to provide this functionality to Airfoil for Windows.

In brief, the process works like this:

1. When Airfoil for Windows starts intercepting audio from an application, it will look for a named pipe called:

\\.\pipe\{process id}_airfoil_metadata

Where {process id} is the process id of the application’s main process. The main process id should be used even if it is a child process that is responsible for creating metadata or handling metadata requests.

Thus if your application’s main process has a process id of 8675, the named pipe you create should be called:

\\.\pipe\8675_airfoil_metadata

2. If Airfoil for Windows is able to connect to that named pipe, it will start sending messages using the Airfoil for Windows Metadata Protocol.

A Sample Implementation

The easiest way to understand this API is via example, so we’ve got a sample C# project you can download here:

Download for Airfoil for Windows Integration Sample
Click to download

All messages are sent across the pipe in the following format:

length;message

The length segment indicates the length of the message segment in UTF-8 encoded bytes.

Once the named pipe connection has been made, the application should begin reading messages sent by Airfoil. The first messages sent across the pipe will be supportsRemoteControl and providesTrackData.

If the application responds to supportsRemoteControl with true, then it must also respond to remotePlayPause, remoteTrackNext, and remoteTrackPrevious, even if it doesn’t take any action in response to those messages.

If the application responds to providesTrackData with true, then it must also respond to requestTrackTitle, requestTrackArtist, requestTrackAlbum, and requestAlbumArt, even if it only responds to those messages with an empty string.

Full details on each method are provided in the README.md file included with the sample code.

Get In Touch

Once you’ve looked over the sample code and documentation, if you have any questions or feedback about the API, just let us know by emailing our hello@rogueamoeba.com address.

Once your application supports track metadata or remote control, be sure to let us know. We can then add your application to our list of applications that provide an enhanced experience with Airfoil for Windows. We hope to hear from you!


Comments for this post have been closed. Thanks for reading!