在你- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
方法,你可以得到视频的网址和播放:
@property (nonatomic,retain) MPMoviePlayerController *moviePlayerController;
if ([mediaType isEqualToString:@"public.movie"])
{
NSURL *aURL = [info objectForKey:UIImagePickerControllerMediaURL];//get the url
// and init the video player using this url
_moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:aURL];
[self.view _moviePlayerController.view];
_moviePlayerController.useApplicationAudioSession = NO;
_moviePlayerController.fullscreen = YES;
[_moviePlayerController play];
}
当然,你必须导入MediaPlayer.framework
编辑:大多数可可项目现在使用arc
,因此上面的代码将要求您自己保留MPMoviePlayerController
实例(如this answer中所述)。
尝试更新代码..! – Sarah 2012-04-04 08:03:38