Commit 08208d662da8f04e19626b97fbc8b4865db7866e
1 parent
d6fa5789
提交更改拍摄完成asset空导致崩溃
Showing
1 changed file
with
18 additions
and
3 deletions
CNLiveAVCamera/Classes/XFPhotoLibraryManager.m
| ... | ... | @@ -292,6 +292,13 @@ |
| 292 | 292 | } error:&error]; |
| 293 | 293 | |
| 294 | 294 | NSLog(@"error1: %@", error); |
| 295 | + if (getCameraVideoCompletionBlock) { | |
| 296 | + if (!assetId || error) | |
| 297 | + { | |
| 298 | + getCameraVideoCompletionBlock(nil,videoUrl,error); | |
| 299 | + return; | |
| 300 | + } | |
| 301 | + } | |
| 295 | 302 | |
| 296 | 303 | // 获取曾经创建过的自定义视频相册名字 |
| 297 | 304 | PHAssetCollection *createdAssetCollection = nil; |
| ... | ... | @@ -314,6 +321,14 @@ |
| 314 | 321 | assetCollectionId = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:blockAssetCollectionName].placeholderForCreatedAssetCollection.localIdentifier; |
| 315 | 322 | |
| 316 | 323 | } error:&error]; |
| 324 | + | |
| 325 | + if (getCameraVideoCompletionBlock) { | |
| 326 | + if (!assetId || error || !assetCollectionId) | |
| 327 | + { | |
| 328 | + getCameraVideoCompletionBlock(nil,videoUrl,error); | |
| 329 | + return; | |
| 330 | + } | |
| 331 | + } | |
| 317 | 332 | |
| 318 | 333 | NSLog(@"error2: %@", error); |
| 319 | 334 | |
| ... | ... | @@ -332,13 +347,13 @@ |
| 332 | 347 | |
| 333 | 348 | |
| 334 | 349 | PHFetchResult<PHAsset *> *res = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil]; |
| 335 | - PHAsset *asset = res[0]; | |
| 350 | + PHAsset *asset = [res firstObject]; | |
| 336 | 351 | NSLog(@"asset:\n%@",asset); |
| 337 | 352 | |
| 338 | 353 | if (getCameraVideoCompletionBlock) { |
| 339 | - if (error) | |
| 354 | + if (error || !asset) | |
| 340 | 355 | { |
| 341 | - getCameraVideoCompletionBlock(nil,nil,error); | |
| 356 | + getCameraVideoCompletionBlock(nil,blockVideoUrl,error); | |
| 342 | 357 | } |
| 343 | 358 | else |
| 344 | 359 | { | ... | ... |