开发者

iPhone: my Video Recorder API code doesn't work

I am trying to implement Video recording functionality for my iPhone 3.0 and iPhone 3.1.2 device as well. I created a sample app for that and kept a button called "Start Video" in a UIView. Then i call the below function code when click Start Video button clicked.

-(IBAction) StartVideo
{

 UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

 imagePickerController.sourceType = UIImagePickerControlle开发者_开发问答rSourceTypeCamera;
    imagePickerController.allowsEditing = YES;

//imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
 imagePickerController.mediaTypes =  [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
    imagePickerController.delegate = self;

 [self presentModalViewController:imagePickerController animated:YES];

 [imagePickerController release];

}

UPDATE: When i check the below code snippet to find video is supported or not, it returns me as Video not support alert as mentioned below. I don't understand what is wrong here?

NSArray *media = [UIImagePickerController availableMediaTypesForSourceType:
                      UIImagePickerControllerSourceTypeCamera];
    if([media containsObject:(id)kUTTypeMovie]) 
    {
        imagePickerController.mediaTypes = [NSArray
                                    arrayWithObjects:(id)kUTTypeMovie,nil];
        [self presentModalViewController:imagePickerController animated:YES];

    } else {
        NSLog(@"Video not supported");
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Nothing"
                                                        message:@"Video not supported"
                                                       delegate:self
                                              cancelButtonTitle:nil
                                              otherButtonTitles:@"Ok", nil];        
        [alert show];
        [alert release];
    }

I tested this code on 3.0 2G and 3.1.2 3G as well, but it is crashing when i click on "Start Video" and going to device home screen. I downloaded some third party free video recording app called "Record Video", it works awesome, does video recording and share files very well. I want to know how to implement recording video on iPhone 3.0, 3.1.2 and 4.0 devices. NOTE: I am testing on 2G and 3G devices only.

Could somenone guide me?

Thank you.

UPDATED:

I tested the code (function: StartVideo) with iPhone 3GS device and it's working as expected. I don't know why does it say as "video not supported" on 2G and 3G phone's.


are you setting a delegate to handle returns by the UIImagePickerController ? you need to set a delegate (possibly the view controller you are presenting the picker from) that implements the UIImagePickerControllerDelegate protocol

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜