Add a method to move multiple tracks to a index.

This commit is contained in:
Damiano Galassi committed 2019-01-28 14:08:53 +01:00
1 parent 3ccde22cd7
commit 1e78b53823
2 files changed
+20 -1

No files matched your search

+2
View File
@@ -127,6 +127,8 @@ typedef void (^MP42FileProgressHandler)(double progress);
- (void)moveTrackAtIndex:(NSUInteger)index toIndex:(NSUInteger)newIndex;
- (void)moveTracks:(NSArray<MP42Track *> *)tracks toIndex:(NSUInteger)newIndex;
/**
* Provides an instance of MP42ChapterTrack that represents the file chapters.
*
+18 -1
View File
@@ -515,12 +515,29 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
id track = [self.itracks objectAtIndex:index];
[self.itracks removeObjectAtIndex:index];
if (newIndex > [self.itracks count] || newIndex > index) {
if (newIndex > self.itracks.count || newIndex > index) {
newIndex--;
}
[self.itracks insertObject:track atIndex:newIndex];
}
- (void)moveTracks:(NSArray<MP42Track *> *)tracks toIndex:(NSUInteger)index {
NSAssert(self.status != MP42StatusWriting, @"Unsupported operation: trying to move tracks while the file is open for writing");
for (id track in tracks.reverseObjectEnumerator)
{
NSUInteger sourceIndex = [self.itracks indexOfObject:track];
[self.itracks removeObjectAtIndex:sourceIndex];
if (sourceIndex < index)
{
index--;
}
[self.itracks insertObject:track atIndex:index];
}
}
- (void)organizeAlternateGroupsForMediaTypes:(NSArray *)mediaTypes withGroupID:(NSUInteger)groupID {
NSArray<MP42Track *> *tracks = [self tracksWithMediaTypes:mediaTypes];
BOOL enabled = NO;