d0ping / DBAttachmentPickerController

This powerful component allows to select different types of files from different sources on your device.
MIT License
254 stars 52 forks source link

Help Please... #9

Open geogerar opened 7 years ago

geogerar commented 7 years ago

Hi, Can you tell me how I can get the original file if this file is video? For foto you have "loadOriginalImageWithCompletion:" For video what I have to use?

Thank you very much for that nice tool!

George Gerardis

d0ping commented 7 years ago

Hi! For getting video data you should use originalFileResource method (DBAttachment object). So you can process PHAsset (or another video data) like as if you would get it from the source

geogerar commented 7 years ago

Hi again!

I Have already try what you propose with NO luck. I post the code to help me about what I am doing wrong, also it will be helpfull if you include an example to assist us with your tool about extracting video.

My code :

DBAttachment attachment = [self.modeldata_image_viewcontroller objectAtIndex:1]; PHAsset phasset = [attachment originalFileResource]; if(phasset.mediaType == PHAssetMediaTypeVideo) { // this is a Video [[PHImageManager defaultManager] requestAVAssetForVideo:phasset options:nil resultHandler:^(AVAsset avAsset, AVAudioMix audioMix, NSDictionary *info) {

            NSURL *url = (NSURL *)[[(AVURLAsset *)avAsset URL] fileReferenceURL];
            self.video_data = [NSData dataWithContentsOfURL:url];

        }];
    }

self.video_data is always = null

Can you help me please?

Thanks in advance for your help!

George Gerardis