如何将video从文档目录保存到图库?
如何将文件目录中的video保存到iOS中的图库,在这里我从服务器下载video并保存在文档目录中,现在我想将其移动到图库。
UISaveVideoAtPathToSavedPhotosAlbum(sourcePath,nil,nil,nil);
你可以通过sourcePath来
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];
追加你的path或文件名来获取sourcePath。
NSString *sourcePath = [documentsDirectory stringByAppendingPathComponent:@"youVideo.mp4"];
首先,您需要获得特定的videopath或文档目录,例如: –
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"youVideo.mp4"]; NSURL *movieURL = [NSURL fileURLWithPath:path]; ALAssetsLibrary* library = [[[ALAssetsLibrary alloc] init] autorelease]; [library writeVideoAtPathToSavedPhotosAlbum:movieURL completionBlock:^(NSURL *assetURL, NSError *error){/*notify of completion*/}];