From 22afab8481f0fbe41300e3622263f9ba051dc8c9 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Mon, 4 Nov 2013 09:47:22 +0100 Subject: [PATCH] next/previous chapter. --- MP42/MP42ChapterTrack.h | 6 ++++-- MP42/MP42ChapterTrack.m | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/MP42/MP42ChapterTrack.h b/MP42/MP42ChapterTrack.h index 45ea0d0..7cc4072 100644 --- a/MP42/MP42ChapterTrack.h +++ b/MP42/MP42ChapterTrack.h @@ -18,12 +18,14 @@ - (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle; + (instancetype)chapterTrackFromFile:(NSURL *)URL; -- (void)addChapter:(NSString *)title duration:(uint64_t)timestamp; -- (void)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp; +- (NSUInteger)addChapter:(NSString *)title duration:(uint64_t)timestamp; +- (NSUInteger)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp; - (void)removeChapterAtIndex:(NSUInteger)index; - (void)removeChaptersAtIndexes:(NSIndexSet *)indexes; +- (NSUInteger)indexOfChapter:(MP42TextSample *)chapterSample; + - (void)setTimestamp:(MP42Duration)timestamp forChapter:(MP42TextSample *)chapterSample; - (void)setTitle:(NSString*)title forChapter:(MP42TextSample *)chapterSample; diff --git a/MP42/MP42ChapterTrack.m b/MP42/MP42ChapterTrack.m index 052555c..045fa02 100644 --- a/MP42/MP42ChapterTrack.m +++ b/MP42/MP42ChapterTrack.m @@ -100,7 +100,7 @@ return [[[MP42ChapterTrack alloc] initWithTextFile:URL] autorelease]; } -- (void)addChapter:(NSString *)title duration:(uint64_t)timestamp +- (NSUInteger)addChapter:(NSString *)title duration:(uint64_t)timestamp { MP42TextSample *newChapter = [[MP42TextSample alloc] init]; newChapter.title = title; @@ -112,9 +112,11 @@ [chapters addObject:newChapter]; [chapters sortUsingSelector:@selector(compare:)]; [newChapter release]; + + return [chapters indexOfObject:newChapter]; } -- (void)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp { +- (NSUInteger)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp { MP42TextSample *newChapter = [[MP42TextSample alloc] init]; newChapter.title = title; newChapter.image = image; @@ -126,6 +128,12 @@ [chapters addObject:newChapter]; [chapters sortUsingSelector:@selector(compare:)]; [newChapter release]; + + return [chapters indexOfObject:newChapter]; +} + +- (NSUInteger)indexOfChapter:(MP42TextSample *)chapterSample { + return [chapters indexOfObject:chapterSample]; } - (void)removeChapterAtIndex:(NSUInteger)index