【发布时间】:2011-01-20 08:18:22
【问题描述】:
我想选择一个位于我 iPhone 中的视频文件,并且必须将它上传到服务器。
由于 UIImagePicker 用于选择照片库中可用的图片或其他模式,是否有任何选项可以以编程方式选择位于我们 iPhone 中的文件?
【问题讨论】:
我想选择一个位于我 iPhone 中的视频文件,并且必须将它上传到服务器。
由于 UIImagePicker 用于选择照片库中可用的图片或其他模式,是否有任何选项可以以编程方式选择位于我们 iPhone 中的文件?
【问题讨论】:
使用资产库。参考这个问题:Accessing Videos in library using AssetsLibrary framework iPhone?
在搜索中,我发现this method 可以使用图像选择器控制器访问视频。
【讨论】:
首先添加MediaPlayer 框架...
然后从 mobile9.com 下载 mp4 类型的视频
然后使用如下代码
NSString *url=[[NSBundle mainBundle] pathForResource: @"video" ofType:@"mp4"];
MPMoviePlayerController *play1= [[MPMoviePlayerController alloc] initWithContentURL:[NSURL
fileURLwithPath:url];
[play1 setOrientation:UIDeviceOrientationPortrait animated:YES];
[paly1 play];
试试这个代码.....它正在工作..
【讨论】:
to select video from photo library use following code:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
[self presentViewController:imagePicker animated:YES completion:NULL];
【讨论】: