The MNAVChapters iOS library reads chapter metadata of audiovisual assets. It reads chapters from MPEG-4 and specifically MP3 files. Although the id3v2 standard specifies the chapter frame since 2005, I couldn't find a C or Objective-C library that parses this frame correctly.
This modest implementation in Objective-C has been inspired by a post over on the auphonic blog.
AVAsset *asset = [self assetWithResource:@"auphonic_chapters_demo" ofType:@"mp3"];
NSArray *chapters = [[MNAVChapterReader new] chaptersFromAsset:asset];
@interface MNAVChapter : NSObject
@property (nonatomic) NSString *title;
@property (nonatomic) NSString *url;
@property (nonatomic) CMTime time;
@property (nonatomic) CMTime duration;
@property (nonatomic) UIImage *artwork;
- (BOOL)isEqualToChapter:(MNAVChapter *)aChapter;
- (MNAVChapter *)initWithTime:(CMTime)time duration:(CMTime)duration;
+ (MNAVChapter *)chapterWithTime:(CMTime)time duration:(CMTime)duration;
@end
MNAVChapters is available through CocoaPods. To install simply add the following line to your Podfile:
pod "MNAVChapters"