You can combine 2 mp3 files as: -
NSMutableData *part1 = [NSMutableData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"file1" ofType: @"mp3"]]; NSMutableData *part2 = [NSMutableData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"file2" ofType: @"mp3"]]; [part1 appendData: part2]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; NSString *myMp3 = [documentsDir stringByAppendingPathComponent: @"final.mp3"]; [part1 writeToFile:myMp3 atomically:YES];
This way you can directly add the file to the file. I used it in one of my applications. This is a bit complicated for other formats where you need to update the file header accordingly, but relatively easier with mp3.
UPDATE:
Well, you should also make sure that the bit rates of the mp3 files you are trying to combine are the same. If they are different, they will merge, but they will play only partially or, possibly, at all. Therefore, make sure that the bit-bit is synchronized with each other.
Apple_iOS0304
source share