CRMediaPickerController拿到视频数据

#pragma mark - CRMediaPickerControllerDelegate

//选取视频或图片后,返回到控制器的时候调用

- (void)CRMediaPickerController:(CRMediaPickerController *)mediaPickerController didFinishPickingAsset:(ALAsset *)asset error:(NSError *)error

{

    if (!error){

        if (asset)

        {

            if ([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]){

                //图片

            }else if ([[asset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]){

                //视频

                ALAssetRepresentation *rep = [asset defaultRepresentation];

                Byte *buffer = (Byte*)malloc((NSUInteger)rep.size);

                NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:(NSUInteger)rep.size error:nil];

                self.videoData = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];

//                self.videoData = data;

                //视频截图

                NSString * urlStr = asset.defaultRepresentation.url.absoluteString;

                [self.addBtn setImage:[UIImage getImageFromVideoURLString:urlStr] forState:UIControlStateNormal];

            }

        }else{

            NSLog(@"没选择");

        }

    }else{

        NSLog(@"%@", error.localizedDescription);

    }

}

你可能感兴趣的:(CRMediaPickerController拿到视频数据)