Add a method to move multiple tracks to a index.
This commit is contained in:
2 files changed
+20
-1
No files matched your search
@@ -127,6 +127,8 @@ typedef void (^MP42FileProgressHandler)(double progress);
|
|||||||
|
|
||||||
- (void)moveTrackAtIndex:(NSUInteger)index toIndex:(NSUInteger)newIndex;
|
- (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.
|
* Provides an instance of MP42ChapterTrack that represents the file chapters.
|
||||||
*
|
*
|
||||||
|
|||||||
+18
-1
@@ -515,12 +515,29 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
id track = [self.itracks objectAtIndex:index];
|
id track = [self.itracks objectAtIndex:index];
|
||||||
|
|
||||||
[self.itracks removeObjectAtIndex:index];
|
[self.itracks removeObjectAtIndex:index];
|
||||||
if (newIndex > [self.itracks count] || newIndex > index) {
|
if (newIndex > self.itracks.count || newIndex > index) {
|
||||||
newIndex--;
|
newIndex--;
|
||||||
}
|
}
|
||||||
[self.itracks insertObject:track atIndex: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 {
|
- (void)organizeAlternateGroupsForMediaTypes:(NSArray *)mediaTypes withGroupID:(NSUInteger)groupID {
|
||||||
NSArray<MP42Track *> *tracks = [self tracksWithMediaTypes:mediaTypes];
|
NSArray<MP42Track *> *tracks = [self tracksWithMediaTypes:mediaTypes];
|
||||||
BOOL enabled = NO;
|
BOOL enabled = NO;
|
||||||
|
|||||||
Reference in new issue
Block a user