views:

306

answers:

2

Any help? Now can get NSSize, duration and its all.

+2  A: 

This functionality may not be built in (I'm honestly not sure), but I do know of two third-party libraries which can tell you the information you need.

  • VLCKit, the framework being used by the newest beta versions of VLC for Mac.
  • libmediainfo, a multi-purpose library that can read practically any bit of information you need out of practically any media file.

I can go into more depth with how to use either of these, but I'd rather only do so if you end up needing me to. Let me know!

Carter Allen
I've edited a link to libmediainfo into your question.
Peter Hosey
test app based on libmediainfo looks pretty good, but i really can't understand how to use it in my project. If you did any objective-c project with this library i would be very appreciative if you share this project with me^ or f you did not objective-c project when just give me some hints how to include and use this library in my project.
Yola
To start out, you'll want to download the MediaInfo dylib. Follow the link above, and find this file: MediaInfo_DLL_0.7.33_Mac_Universal.tar. Download it.Add the .dylib file to your project. If there is more than one dylib in the folder, add the one that is largest.Make sure the dylib file is added to your target's "Link Binary with Libraries" build phase. Then add the path to the Developers/Include directory from the downloaded folder to your Header Search Paths in Xcode. You can then #import "MediaInfoDLL.h" in your code, and follow the included documentation for how to open files.
Carter Allen
+2  A: 

You can do this almost entirely using Spotlight's metadata.

For example, I do the following in one of my apps

MDItemRef fileMetadata=MDItemCreate(NULL,(CFStringRef)eachPath);
NSDictionary *metadataDictionary = (NSDictionary*)MDItemCopyAttributes (fileMetadata,
                                                                                           (CFArrayRef)[NSArray arrayWithObjects:(id)kMDItemPixelHeight,(id)kMDItemPixelWidth,nil]);

This code essentially asks for the pixel width and height for a movie file (to determine if it's the dimension of an HD movie or not is the reason).

The Spotlight Metadata Attributes Reference lists all the available keys for various file types by category. You can probably get the required data this way without doing anything significant, provided that the media type you're examining has a Spotlight plug-in.

Scott Anguish