我正在使用通用 UIPasteboard 在我的音频合成应用程序中实现音频复制功能,以便可以将复制的音频粘贴到MAPI:AudioCopy/AudioPaste或启用Intua 音频共享的应用程序中。过程中似乎存在问题,并且复制的音频未出现在启用 AudioPaste 的应用程序中。
这就是我将音频复制到一般 UIPasteboard 中所做的工作。
NSData *newItemData = [NSData dataWithContentsOfFile:[dataPath stringByAppendingPathComponent:@"converted.wav"]];
// This is the copy operation using the General Pasteboard otherwise known as the Intua Pasteboard
UIPasteboard *board = [UIPasteboard generalPasteboard];
[board setPersistent:TRUE];
NSData *dataFile = newItemData;
if (!dataFile) {
NSLog(@"Can't open file");
}
// Create chunked data and append to clipboard
NSUInteger sz = [dataFile length];
NSUInteger chunkNumbers = (sz / GP_CLIPBOARD_CHUNK_SIZE) + 1;
NSMutableArray *items = [NSMutableArray arrayWithCapacity:chunkNumbers];
NSRange curRange;
for (NSUInteger i = 0; i < chunkNumbers; i++) {
curRange.location = i * GP_CLIPBOARD_CHUNK_SIZE;
curRange.length = MIN(GP_CLIPBOARD_CHUNK_SIZE, sz - curRange.location);
NSData *subData = [dataFile subdataWithRange:curRange];
NSDictionary *dict = [NSDictionary dictionaryWithObject:subData forKey:(NSString *)kUTTypeAudio];
[items addObject:dict];
}
board.items = items;
完成此步骤后,当我启动兼容 AudioPaste 的应用程序时,我看不到刚刚复制的音频。你能在我的音频复制代码中发现任何错误吗?