ios – ALAssetsLibraryWriteVideoCompletionBlock返回未定义的值

ios – ALAssetsLibraryWriteVideoCompletionBlock返回未定义的值,第1张

概述ALAssetsLibraryWriteVideoCompletionBlock返回未定义的值.如果assetURL等于nil,则错误应该不等于nil,即返回给我一些错误描述. 请参阅here的apple文档. 当我录制小视频时,ALAssetsLibraryWriteVideoCompletionBlock返回一个很好的assetURL值,但是当我录制长视频3或4 Gb时,assetURL返回n ALAssetsLibraryWriteVIDeoCompletionBlock返回未定义的值.如果assetURL等于nil,则错误应该不等于nil,即返回给我一些错误描述.

请参阅here的apple文档.

当我录制小视频时,ALAssetsLibraryWriteVIDeoCompletionBlock返回一个很好的assetURL值,但是当我录制长视频3或4 Gb时,assetURL返回nil并且错误返回nil.录制的视频是在tmp文件中,因为我可以在我的应用程序中的temporally文件夹中看到此视频.似乎IOS框架尝试将此临时文件复制到相册并且iPhone没有足够的内存将此临时文件复制到相册并返回此文件的路径(assetURL).

这是iOS框架中的错误吗?如果是这样,有没有办法解决它?

更新:
我的文件小于4GB.谢谢

更新源代码:

-(voID)recorder:(AVCamRecorder *)recorder recordingDIDFinishToOutputfileURL:(NSURL *)outputfileURL error:(NSError *)error    {        if ([[self recorder] recordsAudio] && ![[self recorder] recordsVIDeo]) {    // If the file was created on a device that doesn't support vIDeo recording,it can't be saved to the assets     // library. Instead,save it in the app's documents directory,whence it can be copIEd from the device via    // iTunes file sharing.    [self copyfileTodocuments:outputfileURL];    if ([[UIDevice currentDevice] isMultitaskingSupported]) {        [[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];    }           if ([[self delegate] respondsToSelector:@selector(captureManagerRecordingFinished:)]) {        [[self delegate] captureManagerRecordingFinished:self];    }}else {      ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];    [library writeVIDeoAtPathToSavedPhotosAlbum:outputfileURL                                completionBlock:^(NSURL *assetURL,NSError *error) {                                    if (error) {                                        if ([[self delegate] respondsToSelector:@selector(captureManager:dIDFailWithError:)]) {                                            [[self delegate] captureManager:self dIDFailWithError:error];                                        }                                                                               }                                    if ([[UIDevice currentDevice] isMultitaskingSupported]) {                                        [[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];                                    }                                    if (assetURL!=nil)                                    {                                        if ([[self delegate] respondsToSelector:@selector(captureManagerRecordingFinished:)]) {                                        [[self delegate] captureManagerRecordingFinished:self];                                        }                                    }                                    else                                    {                                        NSLog(@"VIDeo is not saved");                                        Nsstring *alertMsg = [Nsstring stringWithFormat:@"Impossible to copy vIDeo to photo album"];                                        UIAlertVIEw *alert = [[UIAlertVIEw alloc] init];                                        [alert setTitle:@"info"];                                        [alert setMessage:alertMsg];                                        [alert setDelegate:self];                                        [alert addbuttonWithTitle:@"Accept"];                                        [alert show];                                    }                                }];     }}
解决方法 我有几乎相同的问题:只是我试图保存照片,而不是电影;但仍然assetURL为NulL.这是我的代码:

- (voID)imagePickerController:(UIImagePickerController *)picker dIDFinishPickingMediawithInfo:(NSDictionary *)info {ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init];[library writeImagetoSavedPhotosAlbum:(__brIDge CGImageRef)([info objectForKey:UIImagePickerControllerOriginalimage])                          orIEntation:ALAssetorIEntationUp completionBlock:^(NSURL *assetURL,NSError *error) {                              if(error == nil) {                                  _myImageUrl = [Nsstring stringWithFormat:@"%@",assetURL];                                  NSLog(@"%@",assetURL);                              } else NSLog(@"%@",error);                          }];[picker dismissVIEwControllerAnimated:YES completion:nil];}

所以,我猜这个问题与文件的大小无关.

总结

以上是内存溢出为你收集整理的ios – ALAssetsLibraryWriteVideoCompletionBlock返回未定义的值全部内容,希望文章能够帮你解决ios – ALAssetsLibraryWriteVideoCompletionBlock返回未定义的值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1022160.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存