[英]UIImagePickerController - picking video in background from photo library
How to continue picking video from photo library in background mode ?如何在后台模式下继续从照片库中挑选视频?
I mean when I press use
button from imagePickerController - PhotoLibrary
and video is started to get compressing - During this compression process (have attached screenshot) if I press home button(ie go to background)
and then come to foreground
then I got info[UIImagePickerControllerMediaURL]
as null
, so is it possible that app can continue compressing video in background also and return proper url
when come to foreground
?我的意思是当我按下imagePickerController - PhotoLibrary
use
按钮时imagePickerController - PhotoLibrary
和视频开始压缩 - 在这个压缩过程中(附有截图)如果我按下home button(ie go to background)
然后来到foreground
然后我得到info[UIImagePickerControllerMediaURL]
为null
,那么应用程序是否有可能在后台继续压缩视频并在进入foreground
时返回正确的url
?
Screenshot :截屏 :
My didFinishPickingMediaWithInfo
,我didFinishPickingMediaWithInfo
,
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
NSURL *url = info[UIImagePickerControllerMediaURL];
NSLog(@"url : %@",url);
[picker dismissViewControllerAnimated:YES completion:nil];
}
PS : If we record video by camera
and go to background then it will stop recording there and we can use it after coming foreground. PS:如果我们通过camera
录制视频并转到后台,则它会在那里停止录制,我们可以在进入前台后使用它。
I have thought of one workaround - UIBackgroundTaskIdentifier
but it will not work in every case, if video is big then it have time limit, so looking for any other solution!我想到了一种解决方法 - UIBackgroundTaskIdentifier
但它不会在所有情况下都有效,如果视频很大,那么它有时间限制,所以寻找任何其他解决方案!
Any help will be appreciated!任何帮助将不胜感激! :) :)
IF we want to pick video
continuously in background by UIImagePickerController
from photolibrary
during video is compressing and user press home button(app go in background)
then we have to use UIBackgroundTaskIdentifier
for continue execution in background or any other background way which keeps app working in background(less possible thing!).如果我们想在video is compressing and user press home button(app go in background)
期间通过UIImagePickerController
从photolibrary
在后台连续选择video
video is compressing and user press home button(app go in background)
那么我们必须使用UIBackgroundTaskIdentifier
在后台继续执行或任何其他保持应用程序在后台工作的后台方式(不太可能的事情!)。 Now, UIBackgroundTaskIdentifier
has time limit so we can't pick any size of video, so if we restricted video time duration then we can pick it continuously in background something like,现在, UIBackgroundTaskIdentifier
有时间限制,所以我们不能选择任何大小的视频,所以如果我们限制视频的持续时间,那么我们可以在后台连续选择它,比如,
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.videoMaximumDuration = 60.0;
self.backgroundTask = UIBackgroundTaskInvalid;
self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"Background handler called. Not running background tasks anymore.");
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask];
self.backgroundTask = UIBackgroundTaskInvalid;
}];
[self presentViewController:picker animated:YES completion:NULL];
With UIImagePickerController
we can do that much only to pick video in background.使用UIImagePickerController
我们可以做很多事情,只是在背景中选择视频。 If anyone want to pick large video in background then he/she should take look into ALAssetLibrary
or Photos framework
.如果有人想在背景中选择大型视频,那么他/她应该查看ALAssetLibrary
或Photos framework
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.