Reputation: 325
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;
}
Upvotes: 0
Views: 728
Reputation: 325
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
Upvotes: 1