简体   繁体   English

如何将视频保存到自定义相册?

[英]How to save video to custom album?

I'm trying to save a video made in an app to a custom album. 我正在尝试将应用中制作的视频保存到自定义相册。 I've tried the solution proposed on Saving Video in an Album Created , however, these blocks are executed asynchronously resulting in my asset in the result block being nil. 我已经尝试过将视频保存到创建的相册中提出的解决方案,但是,这些块是异步执行的,导致结果块中的资产为零。

I've succeeded in creating the album, writing a video to it doesn't seem to work with the above methods. 我已经成功创建了相册,并向其中编写了视频,但似乎无法使用上述方法。 I have no clue what's going on. 我不知道发生了什么事。 Can someone give me a heads up on this? 有人可以给我提个醒吗?

The url you got is a file url but not an ALAsset url. 您获得的url是文件url,而不是ALAsset url。

You'll need to save that mov to camera roll first and add its asset reference to the custom album. 您需要先将该动作保存到相机胶卷中,然后将其资产参考添加到自定义相册中。

Check out the example code in this tutorial. 在本教程中查看示例代码。

http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/ http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/

for video saving support, just add the function below to the category offered here: http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/ 要获得视频保存支持,只需将以下功能添加到此处提供的类别中即可: http : //www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/

 -(void)saveVideoLocalUrl:(NSURL*)assetURL toAlbum:(NSString*)albumName withCompletionBlock:(SaveImageCompletion)completionBlock
 {
    //add the asset to the custom photo album
    [self writeVideoAtPathToSavedPhotosAlbum:assetURL completionBlock:^(NSURL *assetURL, NSError *error)    {
       NSLog(@"error: %@", [error description]);

       [self addAssetURL: assetURL
              toAlbum:albumName
       withCompletionBlock:completionBlock];
    }];
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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