在iphone中查找并​​存储视频文件路径

时间:2011-07-20 12:53:55

标签: iphone objective-c sqlite

我正在尝试找到视频文件路径并将该路径存储到我的sqlite中我从照片库获取视频为此使用类似的代码

-(IBAction)showVideoLibraryPicker
{
    picker.delegate = self;
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
    {
        picker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeMovie, nil];
        [self presentModalViewController:picker animated:YES];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"Error" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

}

为了拍摄视频我使用此代码

- (IBAction)showVideoPicker {

    //picker = [[UIImagePickerController alloc] init];
    //  
    //  picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    //  picker.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
    //  picker.delegate = self; picker.editing = NO; [self presentModalViewController:picker animated:YES];



    //picker = [[[UIImagePickerController alloc] init] autorelease];
    picker.delegate = self;
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;    
        picker.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];
        [self presentModalViewController:picker animated:YES];
        //[picker setCameraOverlayView:cameraOverlay];
        //      picker.navigationBarHidden = YES;
        //      picker.toolbarHidden = YES;
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"Camera is not available" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }



    // [self presentModalViewController:picker animated:YES];                
}

我很困惑如何获得将该视频路径存储到sqlite的路径。

我找到了照片路径但没有获得视频路径。 为了找到照片路径,我使用像这样的代码

NSData *imageData = UIImagePNGRepresentation(self.imageView.image);
NSData *myImage=[[NSData alloc]initWithData:imageData];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(@"%@",documentsDirectory);

NSString *fullPathToFile = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",camtitle.text]];
[myImage writeToFile:fullPathToFile atomically:YES];
NSLog(@"%@",fullPathToFile);
[myImage release];

我该如何处理视频。我需要帮助才能解决问题 提前致谢

1 个答案:

答案 0 :(得分:1)

PL。通过这个doc

重要的是,实现相机接口的代理,清单2中的链接。

从获取的路径中读取视频文件数据并将其存储到文档文件夹。