2013-12-12 128 views
1

嗨,我必须实现保存电影文件到自定义文件夹,为此我使用NSSavepanel。 我在NSSavepanel新的,所以我没有得到的想法,我怎么AVCaptureMovieFileOutput对象添加到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

这是如何关系到'xcode'或'osx'? – Popeye

+0

这是在Xcode工具上创建的可可应用程序。如果您知道答案,请发帖我在等待接受它 –

+0

仅仅因为您使用'xcode'并不意味着您应该使用'xcode'标记。 'xcode'标签保留用于与'xcode IDE'本身相关的问题 - 比如http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-因为你使用'xcode'并不意味着你应该使用这个标签。 'osx'标签也是为'osx'问题保留的 - 例如http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x请不要使用这些标签为这个问题,因为它是永远不相关的。 – Popeye

回答

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 *[email protected]"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]; 


    }