简体   繁体   中英

iPhone: Merge 2 mp3 files

Can some body explain how we can merge 2 mp3 files on iPhone? is it possible?

Try the following code, it is for concatenation not for mixing. Haven't tested myself, but I will soon

NSMutableData *part1=[NSMutableData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"part1" ofType: @"mp3"]];
NSMutableData *part2=[NSMutableData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"part2" ofType: @"mp3"]];

[part1 appendData: part2];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *mp3file = [documentsDirectory stringByAppendingPathComponent: @"test.mp3"];

[part1 writeToFile: mp3file atomically:YES];

I think it should work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM