我正在使用以下代码录制视频,因为它在iPhone 3Gs和iPhone 4中运行顺畅。但在iPhone 3G中,它无法正常工作。
- (void)imagePickerController:(UIImagePickerController *)picker1 didFinishPickingMediaWithInfo:(NSDictionary *)info
{
printf("\n INSIDE......didFinishPickingMediaWithInfo");
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
printf("\n mediaType = %s",[mediaType UTF8String]);
if ([mediaType isEqualToString:@"public.movie"])
{
NSLog(@"got a movie");
videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
newURL = [videoURL copy];
NSLog(@"Video Url = %@",videoURL);
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:newURL];
if (moviePlayer)
{
//[moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
//[moviePlayer setFullscreen:YES];
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDurationAvailableNotification:)
// name:MPMovieDurationAvailableNotification
//object:moviePlayer];
////moviePlayer.useApplicationAudioSession = NO;
//UIImage *image = [moviePlayer thumbnailImageAtTime:(NSTimeInterval)1.0 timeOption: MPMovieTimeOptionNearestKeyFrame];
//NSData *imgData = UIImagePNGRepresentation(image);
//thumbnailData =[imgData copy];
//printf("\n length of ThumbnailImage Data...%d",[imgData length]);
}
NSData *webData = [NSData dataWithContentsOfURL:videoURL];
webData1 = [webData copy];
myAlertView = [[UIAlertView alloc] initWithTitle:@"Enter the Message title" message:@"................." delegate:self cancelButtonTitle:@"No title" otherButtonTitles:@"Ok",nil];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 80.0);
[myAlertView setTransform:myTransform];
[myAlertView addSubview:messageTitleTextField];
[messageTitleTextField setFont:[UIFont boldSystemFontOfSize:14]];
messageTitleTextField.returnKeyType = UIReturnKeyDone;
messageTitleTextField.keyboardAppearance = UIKeyboardAppearanceDefault;
messageTitleTextField.keyboardType = UIKeyboardTypeDefault;
messageTitleTextField.delegate = self;
[myAlertView show];
//[mview addSubview:myAlertView];
UILabel *theTitle = [myAlertView valueForKey:@"_titleLabel"];
[theTitle setTextColor:[UIColor orangeColor]];
UILabel *theBody = [myAlertView valueForKey:@"_bodyTextLabel"];
[theBody setTextColor:[UIColor whiteColor]];
UIImage *theImage2 = [UIImage imageNamed:@"voicebg.png"];
theImage2 = [theImage2 stretchableImageWithLeftCapWidth:16 topCapHeight:16];
CGSize theSize = [myAlertView frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage2 drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage2 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
myAlertView.layer.contents = (id)[theImage2 CGImage];
[myAlertView release];
//[webData release];
[picker1 dismissModalViewControllerAnimated:YES];
}
}
答案 0 :(得分:0)
3G仅具有捕获功能。一些开发人员通过快速连续捕获多张图片并将其转换为视频来解决这个问题。
这篇blog有一篇关于视频选项可用的文章,它已经有一年了,但希望你能够理解他们所做的一切。