views:

671

answers:

5

I need to write some code that will let me query a m4a file and extract the chapter information out. Including:

  • chapter name
  • chapter start time
  • chapter artwork

I did some quick searching and it seems this is viewed as proprietary information by Apple? I found some discussions, but most were from 2005. Also there have been some similar questions on here, but more for CREATING m4a files with chapters, not querying.

Is this just something I have to DIY, cause there isn't a nice apple API for me to use? Or am I missing something obvious?

Also, ideally I need whatever technique I end up using to work on the iPhone.

A: 

this library should solve your needs, but is not runnable on iphone without jailbreaking I would think. http://wmptagext.sourceforge.net/

oops if you need it to work on iphone there is probably an apple api to get this info. /me looks it sounds like you need to play around with the ipodlibrary library....

http://developer.apple.com/iphone/library/documentation/Audio/Conceptual/iPodLibraryAccess_Guide/UsingTheiPodLibrary/UsingTheiPodLibrary.html#//apple_ref/doc/uid/TP40008765-CH101-SW1

mog
A: 

If the files in question live in the iPod library, maybe you can get your information via the MPMediaLibrary query interface (3.0 upward).

Rhythmic Fistman
Yeah I looked into that, specifically the properties on MPMediaItem. Things like MPMediaItemPropertyTitle and such. But nothing mentions chapters or images related to chapters. Its as though they just skipped over that. Oh well, I guess I am forced to just "roll my own"? Unless someone else has a better idea?
pj4533
If the files live in the iPod library the posibilities of rolling your own are pretty limited. Your app is sandboxed.
Rhythmic Fistman
+1  A: 

The metadata tags system is Apple-proprietary. To work with the tags, you have to (sigh) reverse-engineer it or work with a library that has already done this.

I found the following links, but honestly it seems like you will have to pull out the hex editor.

Binary format info (basic spec for generic tags)

Perl library for working with M4A files.

BobMcGee
thanks thats kinda what i figured. darn. It does look like they are MOVING in that direction though (at least in the iPhone SDK). Cause they have a properties section for podcasts in the SDK docs, but right now it only lists "Title".
pj4533
+1  A: 

Turns out this is much simpler than talked about here in the "answers". Not sure if this works on the iPhone, but I just tested it in a command line app:

QTMovie* movie = [QTMovie movieWithFile:@"filename.m4a" error:nil];

NSInteger numChapters = [movie chapterCount];
NSLog(@"Number of Chapters: %d", numChapters);

NSArray* chapterArray = [movie chapters];
for ( NSDictionary* chapDict in chapterArray )
{
 NSLog(@"%@", [chapDict objectForKey:@"QTMovieChapterName"] );
}

Easy as pie. DOH!

pj4533
A: 

Hmz i have been searching for a way to access this data as well. Any luck so far?

EeKay
pj4533