【发布时间】:2017-04-15 18:18:46
【问题描述】:
我在一个视图中有超过 10 个视频 url,它们来自 Web 服务。我在UITableview 中显示这些视频缩略图。
我正在使用以下代码将这些视频保存到特定文件夹中的画廊
这是我的代码::
NSURL *url = [NSURL URLWithString:Urlstr];
NSData *data = [NSData dataWithContentsOfURL:url];
// Write it to cache directory
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"file.mov"];
[data writeToFile:path atomically:YES];
// After that use this path to save it to PhotoLibrary
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library addAssetsGroupAlbumWithName:@"MyFolderName" resultBlock:^(ALAssetsGroup *group)
{
//How to get the album URL?
// saving the video in gallery though file path and document directory
[library writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:path] completionBlock:^(NSURL *assetURL, NSError *error) {
if (error) {
NSLog(@"%@", error.description);
}else {
NSLog(@"Done :)");
}
}];
}
failureBlock:^(NSError *error) {
//Handle the error
}];
现在的问题是它没有将我的视频保存到我的文件夹中。但它会创建文件夹并将视频保存在画廊的默认视频文件夹中。
请任何人告诉我为什么会这样。
【问题讨论】:
-
你为什么不使用或从github.com/Kjuly/ALAssetsLibrary-CustomPhotoAlbum得到提示
-
hii 极点.. 我已经实现了这个。但这会产生很多错误。
-
你遇到了什么错误?
标签: ios objective-c iphone video alassetslibrary