Feeds

Behind the scenes with Apple's media browser

Integrated advantage

Internet Security Threat Report 2014

With free media browsers available, why use the undocumented Apple one? Well, aside from the fact that it's also free, the Apple media browser has a few additional strings to its bow. One big advantage is that the Apple browser supports the Events feature recently added to iPhoto 7. As far as I know, no other media browser supports this, meaning that photo browsing is much less convenient.

Introducing ILMediaBrowserView

So how do you make use of the Apple browser? This turns out to be simplicity itself. Create a new, windowed, Cocoa application project in Xcode, and drag Apple's private iLifeMediaBrowser.framework into the frameworks section of your project window. You'll find it hiding inside /System/Library/PrivateFrameworks. Now edit your MainMenu.nib file by adding a custom view to it in the usual way. Use Interface Builder's Inspector window to change the custom view's class name to ILMediaBrowserView. Now save and run your application. Voila - you've got an instant media browser!

Didn't work for you? Chances are you're not running Leopard. Apple added the iLifeMediaBrowser framework to the 10.5 SDK, but it's not a part of the 10.4 SDK. Yes, it's perfectly possible to use the Apple Media Browser without problems under Tiger, but it involves a few more wrinkles than there's room to discuss here. Instead, let's look a little deeper at the ILMediaBrowserView object.

By default, the browser operates in audio mode - meaning you'll see a list of all your iTunes albums, podcasts and other media in the usual format. I've added a little code to the demo program to illustrate how to switch modes for photo browsing or movie browsing. As mentioned earlier, when you're browsing photos, you'll see a list of defined iTunes events. If you don't want to use the setCurrentBrowserType: method, there are three distinct methods which switch between the wanted modes as below:


- (void)displayAudioBrowser:(id)sender;
- (void)displayImageBrowser:(id)sender;
- (void)displayMovieBrowser:(id)sender;

All the other available methods are included in ILMediaBrowserView.h, which is included as part of the project. As ever, I used the class-dump utility to create this header file. You'll see that there are a number of options here for customising the appearance of the browser. For example, setTableAlternatingRowColors: can be used to set custom colors for table rows when displaying media:


[_browser setTableAlternatingRowColors: 
    [NSArray arrayWithObjects: 
         [NSColor colorWithCalibratedWhite: 0.2 alpha: 0.8], 
         [NSColor colorWithCalibratedWhite: 0.25 alpha: 0.8], 
       nil]];

Personally, I would be strongly disinclined to mess with that stuff because the last thing you want is to confuse the end user with a weird-looking media browser. If you're planning to embed the browser in a HUD window, though, then some judicious customization would make sense.

In case you're wondering how to actually select media in an application, the answer of course is drag and drop. I've added an editable NSImageView control to the demo program to illustrate the point. More typically, you'd build the image browser into a panel, and drag from there into the main document window. The demo program can be downloaded from here.

Have fun with the Apple media browser. More undocumented naughtiness next time.®

Choosing a cloud hosting partner with confidence

More from The Register

next story
Be real, Apple: In-app goodie grab games AREN'T FREE – EU
Cupertino stands down after Euro legal threats
Download alert: Nearly ALL top 100 Android, iOS paid apps hacked
Attack of the Clones? Yeah, but much, much scarier – report
Microsoft: Your Linux Docker containers are now OURS to command
New tool lets admins wrangle Linux apps from Windows
Bada-Bing! Mozilla flips Firefox to YAHOO! for search
Microsoft system will be the default for browser in US until 2020
Facebook, working on Facebook at Work, works on Facebook. At Work
You don't want your cat or drunk pics at the office
Soz, web devs: Google snatches its Wallet off the table
Killing off web service in 3 months... but app-happy bonkers are fine
prev story

Whitepapers

Why cloud backup?
Combining the latest advancements in disk-based backup with secure, integrated, cloud technologies offer organizations fast and assured recovery of their critical enterprise data.
Forging a new future with identity relationship management
Learn about ForgeRock's next generation IRM platform and how it is designed to empower CEOS's and enterprises to engage with consumers.
5 critical considerations for enterprise cloud backup
Key considerations when evaluating cloud backup solutions to ensure adequate protection security and availability of enterprise data.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
Business security measures using SSL
Examines the major types of threats to information security that businesses face today and the techniques for mitigating those threats.