Feeds

Behind the scenes with Apple's media browser

Integrated advantage

Next gen security for virtualised datacentres

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.®

Secure remote control for conventional and virtual desktops

More from The Register

next story
Why has the web gone to hell? Market chaos and HUMAN NATURE
Tim Berners-Lee isn't happy, but we should be
Microsoft boots 1,500 dodgy apps from the Windows Store
DEVELOPERS! DEVELOPERS! DEVELOPERS! Naughty, misleading developers!
Mozilla's 'Tiles' ads debut in new Firefox nightlies
You can try turning them off and on again
'Stop dissing Google or quit': OK, I quit, says Code Club co-founder
And now a message from our sponsors: 'STFU or else'
Apple promises to lift Curse of the Drained iPhone 5 Battery
Have you tried turning it off and...? Never mind, here's a replacement
Uber, Lyft and cutting corners: The true face of the Sharing Economy
Casual labour and tired ideas = not really web-tastic
Linux turns 23 and Linus Torvalds celebrates as only he can
No, not with swearing, but by controlling the release cycle
prev story

Whitepapers

Gartner critical capabilities for enterprise endpoint backup
Learn why inSync received the highest overall rating from Druva and is the top choice for the mobile workforce.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Rethinking backup and recovery in the modern data center
Combining intelligence, operational analytics, and automation to enable efficient, data-driven IT organizations using the HP ABR approach.
Consolidation: The Foundation for IT Business Transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.