iphonecaf

combine two .caf files


I have used below code to combine two .caf files.

NSMutableData *datas = [NSMutableData alloc];
NSData *data1 = [NSData dataWithContentsOfFile:path1];
NSData *data2 = [NSData dataWithContentsOfFile:path2];
NSLog(@"file1 size  : %d", [data1 length]);
NSLog(@"file2 size : %d", [data2 length]);
[datas appendData:data1];
[datas appendData:data2];
NSLog(@"file3 size  : %d", [datas length]);
[[NSFileManager defaultManager] createFileAtPath:combinedPath contents:datas attributes:nil];

Problem is; I can able to combine two files. But when I try to play the combined file, it is playing only the first file content.

Please help me to resolve it.

Thanks.


Solution

  • I got the solution;

    I have used Audio Queue Services to do this process.

    Click here for documentation.