Ios 多个视频上传的进展
正在查找带有进度视图的多个视频上载示例。 这里我定义了步骤Ios 多个视频上传的进展,ios,nsurlsession,nsurlsessionuploadtask,Ios,Nsurlsession,Nsurlsessionuploadtask,正在查找带有进度视图的多个视频上载示例。 这里我定义了步骤 打开多媒体资料并选择视频 从“多媒体资料”中选择视频,并在编辑所选内容后,创建拇指图像 在tableview或collection view中使用拇指图像显示所有选定的视频 在Tableview或Collection视图中显示视频上载过程并显示进度 如果有人知道怎么做,我会帮上忙的 可能我们可以使用NSUrlsession上载任务,但无法实现 为此,您可以使用 您可以使用以下方法生成所选视频的拇指图像 - (UIImage *)gene
- (UIImage *)generateThumbImage : (NSString *)filepath {
NSURL *url = [NSURL fileURLWithPath:filepath];
AVAsset *asset = [AVAsset assetWithURL:url];
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
imageGenerator.appliesPreferredTrackTransform = YES;
CMTime time = [asset duration];
time.value = 2;
CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:NULL];
UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef); // CGImageRef won't be released by ARC
return thumbnail;
}
NSObject
file类。创建包含imageView和progressView的collectionView。该collectionView类型是文件类型
@interface File : NSObject
@property (nonatomic, strong) NSString *fullFilePath;
@property (nonatomic) float overAllProgress;
- (void)sendFile;
@end
@implementation File
- (void)sendFile {
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://localhost/upload.php" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:[NSURL fileURLWithPath:self.fullFilePath] name:@"photo_path" fileName:self.relativePath mimeType:@"video/quicktime" error:nil];
} error:nil];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
NSURLSessionUploadTask *uploadTask;
uploadTask = [manager
uploadTaskWithStreamedRequest:request
progress:^(NSProgress * _Nonnull uploadProgress) {
// This is not called back on the main queue.
// You are responsible for dispatching to the main queue for UI updates
dispatch_async(dispatch_get_main_queue(), ^{
//Update the progress view
self.overAllProgress = uploadProgress.fractionCompleted;
[[NSNotificationCenter defaultCenter] postNotificationName:@"imageprogress" object:self]
});
}
completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[uploadTask resume];
@end
请检查我的答案并给出回复。嗨,ekta,你有任何关于多个视频上传的示例应用程序吗?没有,我现在没有r8。但是你可以按照这个步骤。希望这会有帮助,你可以理解它是如何工作的。如果你有任何问题,请提问。不要提及。只要放弃投票,如果你觉得有帮助就接受。这就是我的动机D
-(void) viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileProgress:) name:@"imageprogress" object:nil];
}
- (void)viewDidUnload{
[super viewDidUnload];
// Release any retained subviews of the main view.
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"imageprogress" object:nil];
}
- (void)fileProgress:(NSNotification *)notif{
File * info = [notif object];
if([_arrFiles containsObject:info]){
NSInteger row = [_arrFiles indexOfObject:info];
NSIndexPath * indexPath = [NSIndexPath indexPathForRow:row inSection:0];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
[cell.progressView setProgress:info.overAllProgress animated:YES]
}
}