0

我想将视频上传到服务器......并且正在使用 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;
        } 
4

1 回答 1

1

终于从这里得到了解决方案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 expecting
于 2016-09-09T04:28:01.377 回答