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,6 +292,13 @@ | ||
| 292 | } error:&error]; | 292 | } error:&error]; |
| 293 | 293 | ||
| 294 | NSLog(@"error1: %@", error); | 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 | PHAssetCollection *createdAssetCollection = nil; | 304 | PHAssetCollection *createdAssetCollection = nil; |
| @@ -314,6 +321,14 @@ | @@ -314,6 +321,14 @@ | ||
| 314 | assetCollectionId = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:blockAssetCollectionName].placeholderForCreatedAssetCollection.localIdentifier; | 321 | assetCollectionId = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:blockAssetCollectionName].placeholderForCreatedAssetCollection.localIdentifier; |
| 315 | 322 | ||
| 316 | } error:&error]; | 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 | NSLog(@"error2: %@", error); | 333 | NSLog(@"error2: %@", error); |
| 319 | 334 | ||
| @@ -332,13 +347,13 @@ | @@ -332,13 +347,13 @@ | ||
| 332 | 347 | ||
| 333 | 348 | ||
| 334 | PHFetchResult<PHAsset *> *res = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil]; | 349 | PHFetchResult<PHAsset *> *res = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil]; |
| 335 | - PHAsset *asset = res[0]; | 350 | + PHAsset *asset = [res firstObject]; |
| 336 | NSLog(@"asset:\n%@",asset); | 351 | NSLog(@"asset:\n%@",asset); |
| 337 | 352 | ||
| 338 | if (getCameraVideoCompletionBlock) { | 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 | else | 358 | else |
| 344 | { | 359 | { |