2

如何将文档目录中的视频保存到iOS中的画廊,这里我从服务器下载了视频并保存在文档目录中,现在我想将它移动到画廊。

4

2 回答 2

4
UISaveVideoAtPathToSavedPhotosAlbum(sourcePath,nil,nil,nil);

您可以将 sourcePath 作为

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

附加您的路径或文件名以获取 sourcePath。

NSString *sourcePath = [documentsDirectory stringByAppendingPathComponent:@"youVideo.mp4"]; 
于 2013-07-22T06:42:59.277 回答
4

首先,您需要获取特定的视频路径或文档目录,例如:-

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*/}];
于 2013-07-22T06:48:05.677 回答