Ajay
Ajay

Reputation: 552

findig and storing the video file path in iphone

I am trying to find the video file path and get store that path into my sqlite I getting video from the photo lib For that use the code like that

-(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];
    }

}

And for taking video i use this code

- (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];                
}

I am confused how can get the path for storing that video path into sqlite .

I find the photo path but didn't get the video path . For finding the photo path I use the code like this

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];

How can I do for the video also .I need help to solve it out problem Thanks in advance

Upvotes: 0

Views: 839

Answers (1)

Ilanchezhian
Ilanchezhian

Reputation: 17478

Pl. go thru this doc.

Importantly, Implementing a Delegate for the Camera Interface , Listing 2 in that link.

Read the video file data from the obtained path and store that to documents folder.

Upvotes: 1

Related Questions