访问iPhone / iPod视频库

时间:2010-05-19 20:56:37

标签: iphone sdk video

我如何在iPhone视图SDK中访问视频厨房。 我必须用什么来完成这项任务。

我想在我的应用中显示所有视频(在iPhone / iPod上),然后在网络服务器上上传所选视频。

感谢。

4 个答案:

答案 0 :(得分:1)

选择视频的起始点为UIImagePickerController,播放时为MPMoviePlayerControllerMPMoviePlayerViewController

答案 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];