您好我必须将保存电影文件实现到自定义文件夹中,为此我使用的是NSSavepanel。 我是NSSavepanel的新手,所以我不知道如何将AVCaptureMovieFileOutput对象添加到NSSavePanel
我的代码是
-(void)doSaveDocument
{
NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel setTitle:@"Save image"];
[savePanel setNameFieldStringValue:@"AnnotatedImage.mov"];
if([savePanel runModal] == NSFileHandlingPanelOKButton)
{
[self takeScreenRecording:rect saveAtPath:[savePanel URL]];
[[NSWorkspace sharedWorkspace] openURL:[savePanel URL]];
[mMovieFileOutput startRecordingToOutputFileURL:[savePanel URL] recordingDelegate:self];
}
}
答案 0 :(得分:0)
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory1 = [paths1 objectAtIndex:0]; // Get documents folder
NSString *dataPath = [documentsDirectory1 stringByAppendingPathComponent:@"MyVideo"];
NSError *error;
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];
NSString *stryourfilename=@"Video1";
dataPath=[NSString stringWithFormat:@"%@/%@.mp4",dataPath,stryourfilename];
NSData *dat=[NSData dataWithContentsOfURL:videoURL];
BOOL ok = [[NSFileManager defaultManager] createFileAtPath:dataPath
contents:nil attributes:nil];
if (!ok) {
} else {
NSFileHandle* myFileHandle = [NSFileHandle fileHandleForWritingAtPath:dataPath];
[myFileHandle writeData:dat];
[myFileHandle closeFile];
}