0

I want to upload video to server... and am using elcImagePickerController to select multiple/single video

But in

 - (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info

method am not getting UIImagePickerControllerMediaURL to get data..

so how to get video data to send it to server?

This is my code

    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;
        } 
kb920
  • 3,039
  • 2
  • 33
  • 44
Akshay Ambekar
  • 325
  • 1
  • 3
  • 14
  • [this post may help!!](http://stackoverflow.com/questions/9931779/use-elcimagepickercontroller-to-pick-video) – Ketan Parmar Sep 08 '16 at 10:49
  • no :( am able to display inly video/images but unable to get NSData of video... – Akshay Ambekar Sep 08 '16 at 11:09
  • http://stackoverflow.com/questions/33189012/swift2-how-to-convert-video-in-gallary-to-nsdata-in-swift-2 – Larme Sep 08 '16 at 11:16
  • am not getting UIImagePickerControllerMediaURL in didFinishPickingMediaWithInfo... instead am getting UIImagePickerControllerReferenceURL... @Larme – Akshay Ambekar Sep 08 '16 at 11:19
  • I suggest to use native `UIImagePickerController`. It have sufficient methods available to achieve any kind of task and are easy and simple to implement. No need to use third party for media picking!! – Ketan Parmar Sep 08 '16 at 12:27
  • But I want to select multiple videos and images... is it possible in native UIImagePickerController? @ketan – Akshay Ambekar Sep 08 '16 at 12:34
  • ohh! Actually everything can be achieved by native methods or apis because thirdparty libraries itself use native methods. If you want to select multiple media then it can be achieved by `AssetsLibrary` and it is very long process so in this case it is better to use thirdparty. :) So find the way with `ELCImagePickerController`. You can ask in github also! – Ketan Parmar Sep 08 '16 at 12:47

1 Answers1

1

Finally got solution from here 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
Community
  • 1
  • 1
Akshay Ambekar
  • 325
  • 1
  • 3
  • 14