- NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectoryPath = [dirs objectAtIndex:0];
- NSString *filePath1 = [[documentsDirectoryPath stringByAppendingPathComponent:@"exported.caf"] retain];
- NSString *filePath2 = [[documentsDirectoryPath stringByAppendingPathComponent:@"exported.caf"] retain];
- NSString *filePath3 = [[documentsDirectoryPath stringByAppendingPathComponent:@"exported.caf"] retain];
- NSString *filePath4 = [[documentsDirectoryPath stringByAppendingPathComponent:@"exported.caf"] retain];
- NSString *filePath5 = [[documentsDirectoryPath stringByAppendingPathComponent:@"exported.caf"] retain];
- NSString *filePath6 = [[documentsDirectoryPath stringByAppendingPathComponent:@"b.caf"] retain];
- AVMutableComposition* composition = [AVMutableComposition composition];
- AVURLAsset* audioAsset1 = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:filePath1] options:nil];
- AVURLAsset* audioAsset2 = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:filePath2] options:nil];
- AVURLAsset* audioAsset3 = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:filePath3] options:nil];
- AVURLAsset* audioAsset4 = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:filePath4] options:nil];
- AVURLAsset* audioAsset5 = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:filePath5] options:nil];
- AVMutableCompositionTrack *audioTrack1 = [composition addMutableTrackWithMediaType:AVMediaTypeAudio
- preferredTrackID:kCMPersistentTrackID_Invalid];
- [audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset1.duration)
- ofTrack:[[audioAsset1 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
- atTime:kCMTimeZero
- error:nil];
- [audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset2.duration)
- ofTrack:[[audioAsset2 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
- atTime:audioAsset1.duration
- error:nil];
- [audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset3.duration)
- ofTrack:[[audioAsset3 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
- atTime:audioAsset1.duration
- error:nil];
- [audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset4.duration)
- ofTrack:[[audioAsset4 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
- atTime:audioAsset1.duration
- error:nil];
- [audioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAsset5.duration)
- ofTrack:[[audioAsset5 tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0]
- atTime:audioAsset1.duration
- error:nil];
- [self exportAsset:audioTrack1.asset toFilePath:filePath6];