如何以编程方式选择视频文件并上传到 iPhone 中的服务器

发布于 2024-10-12 15:16:25 字数 111 浏览 1 评论 0原文

我想选择 iPhone 中的一个视频文件并将其上传到服务器。

由于 UIImagePicker 用于选择照片库或其他模式中可用的图片,是否有任何选项可以以编程方式选择 iPhone 中的文件?

I want to select an video file located in my iPhone and have to upload it to the server.

As UIImagePicker is used to select pictures available in our photo library or some other mode, is any option to select a file located in our iPhone programmatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

当梦初醒 2024-10-19 15:16:25

使用资产库。请参阅此问题:使用 AssetsLibrary 框架 iPhone 访问库中的视频?

在搜索时,我发现 这种方法 使用图像选择器控制器访问视频。

Use Assets library. Refer this question: Accessing Videos in library using AssetsLibrary framework iPhone?

And on searching, I found this method to access videos using image picker controller.

冷弦 2024-10-19 15:16:25

首先添加 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];

尝试此代码...它正在工作..

First Add the MediaPlayer Framework...

Then download video of type mp4 from mobile9.com

then use the code as follows

NSString *url=[[NSBundle mainBundle] pathForResource: @"video" ofType:@"mp4"];

MPMoviePlayerController *play1= [[MPMoviePlayerController alloc] initWithContentURL:[NSURL 
fileURLwithPath:url];

[play1 setOrientation:UIDeviceOrientationPortrait animated:YES];

[paly1 play];

try this code .....it's working..

泛滥成性 2024-10-19 15:16:25
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];
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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文