0

I have a url of video from photo library :-

/var/mobile/Applications/9BC2EBC4-7A71-4C8B-8BFB-D25D01E4CA83/Documents/IMG_5244.MOV

How can i get convert it to NSData I am tried following but nothing worked:

NSString* fileName = movieAsset.defaultRepresentation.filename;
                NSURL* fileUrl = [[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]lastObject]URLByAppendingPathComponent:fileName];
                NSString *str = [fileUrl path];
                NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
                [arrVideoUrls addObject:fileUrl];
Priyanka
  • 207
  • 2
  • 10

1 Answers1

0

Here in your code you have add NSString as an URL and try to convert that NSString URL to NSData, so here first convert that string url to NSURL and then convert it in to NSData like below...

NSString *strVideoURL = @"assets-library://asset/asset.MOV?id=2EBD925F-D275-403E-A6A4-3487134D9B9D&ext=MOV"; 
NSURL *urlVideo = [NSURL URLWithString:strVideoURL]; 
NSData *videoData = [NSData dataWithContentsOfURL:urlvideo]];
Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • This is also not working . i have tried this as well – Priyanka Jun 30 '15 at 10:19
  • now try this code with your static URL and let me know if you will get response from this. – Paras Joshi Jun 30 '15 at 10:34
  • so here you need to provide whole code related to this video url or check these answers http://stackoverflow.com/questions/17585908/how-can-i-get-the-list-of-all-video-files-from-library-in-ios-sdk – Paras Joshi Jun 30 '15 at 10:42