• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
ID3 tags from AAC files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ID3 tags from AAC files


  • Subject: ID3 tags from AAC files
  • From: Jeremy Dronfield <email@hidden>
  • Date: Wed, 5 Jan 2005 14:30:41 +0000

Is there a way to extract ID3 tags from AAC (.m4a) files encoded with iTunes? I've been using QuickTime GetMovieUserData() to extract tags from NSMovies created from mp3 tracks, but the same method doesn't work with m4a files.

The code I'm using is based on the QT example at <http://developer.apple.com/qa/qa2001/qa1135.html>. Can anyone suggest what modifications might be necessary to use this with AAC tracks? I assume the ID3 tags must be preserved in the converted files, since iTunes presumably uses them.

#import <QuickTime/Movies.h>

const UInt8 kUserDataIsText = 0xA9; // the copyright symbol

- (void)printTags
{
	NSURL *trackURL = [NSURL fileURLWithPath:filePath];
	NSMovie *track = [[NSMovie alloc] initWithURL:trackURL byReference:NO];
	UserData inUserData = GetMovieUserData([track QTMovie]);

	OSType udType;
	short count, i;
	char nul = 0;
	Handle hData = NULL;
	Ptr p;
	OSErr err = noErr;
	hData = NewHandle(0);
	udType = GetNextUserDataType(inUserData, 0);
	if(0 != udType) {
		NSLog(@"\nMeta-data:\n";);
		do {
			count = CountUserDataType(inUserData, udType);
			for(i = 1; i <= count; i++) {
				if((udType>>24) == kUserDataIsText) {
					err = GetUserDataText(inUserData, hData, udType, i, langEnglish);
					if (err) goto bail;
					PtrAndHand(&nul, hData, 1);
					p = *hData;
					while(*p) {
						if (*p == kReturnCharCode)
							*p = ' ';
						p++;
					};
					HLock(hData);
					NSLog(@"  %c%c%c%c: %s\n", (char)(udType>>24),
						   (char)(udType>>16),
						   (char)(udType>>8),
						   (char)udType, *hData);
					HUnlock(hData);
				} else {
					err = GetUserData(inUserData, hData, udType, i);
					if (err)
						goto bail;
					NSLog(@"  %c%c%c%c: [%d bytes]\n",
						   (char)(udType>>24),
						   (char)(udType>>16),
						   (char)(udType>>8),
						   (char)udType, GetHandleSize(hData));
				}
			}
			udType = GetNextUserDataType(inUserData, udType);
		}
		while(0 != udType);
	}
bail:
		NSLog(@"\n");
	DisposeHandle(hData);
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: ID3 tags from AAC files
      • From: "Sean McBride" <email@hidden>
    • Re: ID3 tags from AAC files
      • From: Yann Bizeul <email@hidden>
  • Prev by Date: Re: [Newbie] How to make application reappear after a close?
  • Next by Date: Re: Preferences UI operation theory
  • Previous by thread: Re: [Newbie] How to make application reappear after a close?
  • Next by thread: Re: ID3 tags from AAC files
  • Index(es):
    • Date
    • Thread