简体   繁体   中英

Save photo to iPhone Photo album from dowloaded NSData object

I download the data from a URL of video in NSData form. Now how can I store it to iphone Photoalbum? Is there any way to convert NSData to video back or we can directly save it to photo album?

If you can play the movie in a MPMoviePlayerController object then it should return true when checked by UIVideoAtPathIsCompatibleWithSavedPhotosAlbum().

If so, then you can save it to the Photo Library using this function:

void UISaveVideoAtPathToSavedPhotosAlbum (
   NSString  *videoPath,
   id        completionTarget,
   SEL       completionSelector,
   void      *contextInfo
);

Alternatively, you can create and ALAssetsLibrary object and save it using using the this method:

- (void)writeVideoAtPathToSavedPhotosAlbum:(NSURL *)videoPathURL completionBlock:(ALAssetsLibraryWriteVideoCompletionBlock)completionBlock

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM