我如何在iPhone视图SDK中访问视频厨房。 我必须用什么来完成这项任务。
我想在我的应用中显示所有视频(在iPhone / iPod上),然后在网络服务器上上传所选视频。
感谢。
答案 0 :(得分:1)
选择视频的起始点为UIImagePickerController
,播放时为MPMoviePlayerController
和MPMoviePlayerViewController
。
答案 1 :(得分:0)
首先,创建一个UIImagePickerController
在您的课程中,您需要实施UIImagePickerControllerDelegate协议并将其连接到选择器上的delegate
属性。一旦用户选择了某些内容,您就应该能够从didFinishPickingMediaWithInfo
中获取所选媒体的位置。
// untested
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// this is the file system url of the media
NSURL* videoUrl = [info objectForKey:UIImagePickerControllerMediaURL];
// TODO: read in data at videoUrl and write upload it to your server
}
答案 2 :(得分:0)
如果您使用UIImagePickerController
,请务必使用sourceType
属性来访问库而不是实时相机。有关详细信息,请参阅UIImagePickerControllerSourceType
。
以下是您的选择:
enum {
UIImagePickerControllerSourceTypePhotoLibrary,
UIImagePickerControllerSourceTypeCamera,
UIImagePickerControllerSourceTypeSavedPhotosAlbum
};
答案 3 :(得分:0)
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
NSArray *mediaTypesAllowed = [NSArray arrayWithObjects:@"public.image", @"public.movie", nil];
[imagePickerController setMediaTypes:mediaTypesAllowed];
[self presentModalViewController:imagePickerController animated:YES];