【发布时间】:2010-05-19 20:56:37
【问题描述】:
如何在我的 iPhone 视图 SDK 中访问视频厨房。 我必须使用什么对象来完成该任务。
我想在我的应用中显示所有视频(在 iPhone/iPod 上),然后将选定的视频上传到网络服务器上。
谢谢。
【问题讨论】:
如何在我的 iPhone 视图 SDK 中访问视频厨房。 我必须使用什么对象来完成该任务。
我想在我的应用中显示所有视频(在 iPhone/iPod 上),然后将选定的视频上传到网络服务器上。
谢谢。
【问题讨论】:
起点UIImagePickerController选择视频,MPMoviePlayerController和MPMoviePlayerViewController进行播放。
【讨论】:
首先,创建一个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
}
【讨论】:
如果您使用UIImagePickerController,请务必使用sourceType 属性来访问库而不是实时摄像头。详情请见UIImagePickerControllerSourceType。
这些是您的选择:
enum {
UIImagePickerControllerSourceTypePhotoLibrary,
UIImagePickerControllerSourceTypeCamera,
UIImagePickerControllerSourceTypeSavedPhotosAlbum
};
【讨论】:
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];
【讨论】: