Does anyone know how to extract the kind of detailed file info which you can get in the finder using “Get Info”? In particular, I am interested in retrieving info on my .mp3 files like Album, Title, Year recorded, Sample rate, etc.
Please DO NOT point me to any third party plug-ins.
(Looks like the second part of your question got more attention than the first.)
Step back a second. All data files are filled with… data. Overall, there aren’t too many classes in REAL/Xojo itself that “extract” specific data or metadata out of files and represent them. For example, the Sound object is just to play the sound, it doesn’t show you the samplerate or bitrate or channel characteristics of the sound itself.
Graphic files, sound files, 3D files, all have this type of stuff and generally it’s up to you to find the file format information and parse the file yourself to get this data. MP3 files use what got called the ID3 tag structures and you can google them and find it on the web.
Stepping backwards into your question, OSX and Windows have built-in HANDLERS that parse this information for the purposes of their property sheets (GetInfo). Mostly these aren’t available for others to use. They’ve done the work, but they use it for themselves. You generally have to do the work yourself. Or, if you are looking for someone else to have done the work, you are talking plugins, which you eliminated as a possibility in your second paragraph. This is what plugins or reusable code is primarily for.
What is the best way to read the raw data from the file so I can parse it?
I think I could extract the info, but I’m not sure exactly how to obtain it. I assume it means grabbing the first few block of data from the file and looking for the ID3 tags.
So, please, what is the best approach to opening a file and reading the required data blocks?
Ed, I agree, the hex sleuthing is fun! But with the specs, which are easy to find, it’s easy to figure it out. Get the ID3 specs and you’ll find it rather easy.
Make sure you look at the latest one.
Older specs didn’t account for tags at the end of the file so if you used that spec then you couldn’t handle all files.
And don’t be too new since that may yet be “draft” and never implemented that way.
Web sockets kind of did this where they published a spec then it changed after a lot had implemented it based on that draft and that draft did not become the final.
And there are certain de facto standard that have no published spec
[quote=64127:@Ed Stokes]Does anyone know how to extract the kind of detailed file info which you can get in the finder using “Get Info”? In particular, I am interested in retrieving info on my .mp3 files like Album, Title, Year recorded, Sample rate, etc.
[/quote]
There are several ways to get this information, NSURL has a whole bunch of functions for getting file information as well as Spotlight APIs.
The MBS will make this relatively easy (especially with documentation and examples), the MacOSLib is FREE, but will take a bit to figure out, where as declares are the hardest.
This is an old post, and all the above links have been corrupted (pointing to Mackeeper, and off the wall media players, and not to anything resembling examples etc).
SO… Does anyone have XOJO code that will read ID3v2.x formats. ID3V1 is super easy.
I need to be able to scan a computer for all MP3 files, and present them in an “iTunes” like manner, to build file packages to transfer directly to a Garmin Zumo GPS unit
Check your internet plugins folder and various other places, my brother-in-laws Mac was loaded with some adware on his machine. I think I’ve cleaned it all. There’s some articles on MacWorld for removing this disgusting piece of ■■■■ from your system. Every time he clicked on a link, he got a second window advertising MacKeeper.
Also check in the application support folder (users folder) for a hidden directory called .FUS.