Under The Microscope

Archive for April, 2011

Airfoil Works Great With Third-Party AirPlay Devices

Back in September, Apple announced AirPlay, the updated and renamed version of their streaming audio technology previously called AirTunes. As part of that update, Apple announced that third-party hardware developers would soon be releasing hardware which could receive audio from iTunes, just as the AirPort Express and Apple TV have long done. Naturally, we wanted to be sure that Airfoil worked fully with these new audio devices as well, to enable users to send any audio out. It’s taken quite awhile for the devices to come out, but we finally acquired one, the JBL On Air Wireless.

Once we had the device, we tested it out with the currently-shipping version of Airfoil. It worked great, right out of the box (one caveat: the device’s icon incorrectly shows as an old-style Apple TV, an issue we’ll fix in our next update). Just open up Airfoil, and you’ll see your third-party device waiting to receive audio. Here it all is in action:

Airfoil sending to the On Air

Airfoil sending audio to the JBL On Air

The On Air, receiving audio

The JBL On Air, receiving audio from Pulsar

As you can see, audio is coming in from Pulsar to Airfoil, where it’s then transmitted out to the On Air. Even better, the On Air’s LCD display is displaying artwork and now playing info from Pulsar, provided by Airfoil!

In addition to the On Air, we’ve also heard from users who are using the Bowers & Wilkins Zeppelin Air with much success. So if you’re considering any third-party AirPlay device and you’re curious if it’ll work with Airfoil, wonder no longer! Download Airfoil now, and enjoy!

If you’ve got other questions about AirPlay and Airfoil, be sure to see this Q&A post.

Developer Note: Integrating with Airfoil

Among the many improvements included in Airfoil 4, two of particular interest to third-party developers are track metadata display and source remote control. If you make any kind of media playing application, this post is for you. With just a few minutes work, you can get your application to integrate with Airfoil and Airfoil Speakers, so your users can see what’s playing and control playback as well.

The Basics

Airfoil automatically gathers metadata such as track titles and album artwork from supported applications. That metadata is shown when transmitting to Airfoil Speakers or an Apple TV. Currently, Airfoil has built-in track metadata support for iTunes and QuickTime Player, as well as our own applications Airfoil Video Player and Pulsar.

Metadate in Airfoil Speakers

Meanwhile, remote control allows the playback of a transmitted application to be controlled directly in Airfoil Speakers, 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. Remote control support is currently built in for iTunes, QuickTime Player, Pulsar, and VLC.

Playback Controls in Airfoil Speakers

How It Works

Both track metadata and remote control are supported by Airfoil via Applescript. This means that support can be added for additional applications simply by adding more Applescripts. So, if your application is scriptable, it can take advantage of Airfoil’s new features by providing Applescript support for track metadata properties and remote control commands.

Airfoil has a kind of Applescript API, which we’ve been using internally. Now we’re documenting the API publicly for third-party developers.

To integrate with Airfoil, your application should handle five Applescript properties — track title, artist, album, duration, and logo — and three Applescript commands — playpause, next, and previous.

A Sample Implementation

The easiest way to explain this Applescript API is to provide an example, so we’ve got a sample Xcode project called Airfoil Integration Sample.

Download for Airfoil Integration Sample

Click to download

The scripting definition for Airfoil Integration Sample is in the file AppleScriptSuite.sdef. The names of the properties and commands (as well as codes, descriptions, and classes in the sdef file) can be customized as needed for your own application. What’s crucial is the type and functionality of each item. The track title, artist, and album properties should all return a string, the duration property should return an integer representing the length of the track in seconds, and the logo property should return TIFF image data. The playpause command should start and stop the audio of the current track, while the next and previous commands should switch to the next or previous track.

In the file AirfoilIntegrationSampleAppDelegate.m, you can see how the Applescript properties and commands are implemented in Cocoa. The string properties are represented by NSString, the duration property by NSNumber, and the logo property by NSData. Note that any of the property methods can also return nil, which corresponds to missing value in Applescript. This is the way to let Airfoil know that a track does not have a particular property.

Once your application supports the appropriate Applescript properties and commands, they can be tested with actual scripts. Airfoil Integration Sample comes with the scripts dacp.com.rogueamoeba.AirfoilIntegrationSample.scpt for remote control and com.rogueamoeba.AirfoilIntegrationSample.scpt for track metadata. When Airfoil transmits an application, it looks for scripts within the Airfoil bundle1, corresponding to the source application’s bundle identifier. New remote control scripts can be placed in the Application Support folder to be loaded by Airfoil:

~/Library/Application Support/Airfoil/RemoteControl/

~/Library/Application Support/Airfoil/TrackTitle/

For track metadata support, it is essential that your script returns the metadata items in the correct order:

  1. Track title
  2. Artist
  3. Album
  4. Duration
  5. Logo

Note that you can substitute missing value for any of the five items.

For remote control, you need to support at least the remote_play, remote_pause, remote_previous_item, and remote_next_item items in the script, which will call your Applescript commands playpause, previous, and next.

Get In Touch

Once your application supports track metadata or remote control, just let us know by emailing our hello@rogueamoeba.com address. We can then include your scripts in an update to Airfoil.


Footnotes:

  1. You can find existing scripts in Airfoil.app/Contents/Resources/RemoteControl and Airfoil.app/Contents/Frameworks/TrackTitles.framework/Resources/Applescripts   

Audio Hijack Pro and Firefox 4 (Also, Chrome)

Update (June 20th, 2011): With the release of Audio Hijack Pro 2.9.12, the information below is made obsolete. Get the latest Audio Hijack Pro, then just hijack right from your browsers!

Audio Hijack Pro IconIf you’ve used Audio Hijack Pro, you probably know it’s great for recording any audio. One of its most popular uses is to record audio from a web browser. If you want to record audio from sites like Pandora.com or Last.fm for offline listening, Audio Hijack Pro can help. Normally, this is as simple as setting the web browser as your audio source, then pressing Record.

In the past two years or so, however, recording from web browsers has become a bit more difficult. With Mac OS X 10.6 (Snow Leopard), Safari began using a background process for its audio plugins when in 64-bit mode1. Audio Hijack Pro works around this by relaunching Safari as 32-bit when required. This suffices, but the hassle has led many users to use different browsers, such as Firefox or Chrome, for their audio capturing.

More recently, Firefox 4 and Google Chrome also changed the way they play audio. They now use background processes for their plugins, just like Safari. Worse, they do it in 32-bit mode too, which means that this can’t be worked around in the same way as Safari. The net result here is that simply selecting Firefox or Chrome won’t grab any audio in Audio Hijack Pro.

Fear not, however! Audio Hijack Pro can capture this audio – it just takes a bit more setup. We’ve got instructions in our Knowledge Base. Check those out, and you should once again be able to grab your web-based audio.

In the meantime, we’re working on improving this. In a future update, we hope to once again make it possible to simply select your source. So, follow the instructions for now, and keep your eye out for updates.


Footnotes:

1. The AHKit1 framework upon which Audio Hijack Pro is built can’t capture background processes. You may notice our audio transmitting app Airfoil can grab this audio. That’s because it uses our newer and more robust AHKit2 framework. Future versions of Audio Hijack Pro will use this as well, but those are still in development. 

Hear All About Us: Airfoil 4′s A Hit

Macworld 4.5 MiceAirfoil 4 came out back in December, but we’ve been anxiously awaiting our review from Macworld. Well it’s out now, and we’ve got a hit! Chris Breen and the Macworld staff have awarded us 4.5 mice (out of 5). Give the full review a read, then grab Airfoil for yourself.

As far as a few notes from Chris’s review, well, we’ll just tell both him, and you, to stay tuned. Watch this very blog (you can subscribe to the RSS feed) and follow us on Twitter. We’re hard at work on updates for Airfoil Speakers Touch, as well as a new application.

Meanwhile, over on the Mac Geek Gab, co-host Dave Hamilton always knows what’s up when it comes to audio. On episode #322, he had a two tips for a listener who wanted to get specific audio out to an audio device. Using either Audio Hijack Pro or Airfoil (coupled with Airfoil Speakers), you can get specific audio out to specific audio devices. Give a listen for more details (this particular segment is about 45 minutes in)!