我想上传视频到服务器...我正在使用elcImagePickerController选择多个/单个视频
但在
- (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info方法无法获取UIImagePickerControllerMediaURL来获取数据..
那么如何获取视频数据并将其发送到服务器?
这是我的代码
if ([dict objectForKey:UIImagePickerControllerOriginalImage]){
UIImage* image=[dict objectForKey:UIImagePickerControllerOriginalImage];
[images addObject:image];
NSURL *imagePath = [dict objectForKey:UIImagePickerControllerReferenceURL];
NSString *imageName = [imagePath lastPathComponent];
[imgNames addObject:imageName];
UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
imageview.frame = workingFrame;
[_scrollView addSubview:imageview];
workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
} 发布于 2016-09-09 12:28:01
终于从这里得到了解决方案https://stackoverflow.com/a/10799693/6011616
ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:[NSURL URLWithString:videoLink] resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc(rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
NSLog(@"%@",data); //this is what I was expectinghttps://stackoverflow.com/questions/39388772
复制相似问题