开发者

Capture Video and send this video in MFMailComposer in iphone

In my app, I have write this code for capture video

  -(IBAction)takeVideo:(id)sender {

        [self startCameraControllerFromV开发者_开发技巧iewController: self

                                        usingDelegate: self]; 
}

    - (BOOL) startCameraControllerFromViewController: (UIViewController*) controller usingDelegate: (id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>) delegate {

        if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil))

            return NO;

        cameraUI = [[UIImagePickerController alloc] init];

        cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;

        // Displays a control that allows the user to choose picture or

        // movie capture, if both are available:

        cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];

        // Hides the controls for moving & scaling pictures, or for

        // trimming movies. To instead show the controls, use YES.

        cameraUI.allowsEditing = NO;
        cameraUI.delegate = delegate;

        [controller presentModalViewController: cameraUI animated: YES];

        return YES;      }


    - (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker {

        [[picker parentViewController] dismissModalViewControllerAnimated: YES];

        [picker release];   
 }

    - (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {


        // Handle a movie capture       cameraUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];    NSString
    *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
        if (CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) {



            NSString *moviePath = [[info objectForKey: UIImagePickerControllerMediaURL] path];

            if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {

                     UISaveVideoAtPathToSavedPhotosAlbum (moviePath, nil, nil, nil);
            }
        }
        [[picker parentViewController] dismissModalViewControllerAnimated: YES];
        [picker release];   
 }

compile and run this code, its working and after taking video i pressed use button to save video then app is crashed and display "EXC_BAD_ACCESS" error msg on terminal

so, pls help me how to solve this error


In iOS 4 or later you can use an instance of UIImagePickerController to capture video. This is a fairly high-level convenience class, so the degree to which you can control the capture and then manipulate the captured video is limited. You might have to resort to lower level APIs available in AV Foundation.

Once you have the video data, you should be able to attached it to your composed e-mail as a mime attachment. You simply need the video in an NSData object and must specify the MIME type for the attachment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜