From b6ef75ce89b14f5eaaa594f95e102e9feb3ce41b Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 26 Jun 2019 09:10:03 -0700 Subject: [PATCH] updated to support new library manager (Using the Photos framework) --- ASScreenRecorder/ASScreenRecorder.m | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ASScreenRecorder/ASScreenRecorder.m b/ASScreenRecorder/ASScreenRecorder.m index 3b92d5e..5593654 100644 --- a/ASScreenRecorder/ASScreenRecorder.m +++ b/ASScreenRecorder/ASScreenRecorder.m @@ -10,6 +10,7 @@ #import #import #import +#import @interface ASScreenRecorder() @property (strong, nonatomic) AVAssetWriter *videoWriter; @@ -195,13 +196,19 @@ - (void)completeRecordingSession:(VideoCompletionBlock)completionBlock; if (self.videoURL) { completion(); } else { - ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; - [library writeVideoAtPathToSavedPhotosAlbum:_videoWriter.outputURL completionBlock:^(NSURL *assetURL, NSError *error) { - if (error) { - NSLog(@"Error copying video to camera roll:%@", [error localizedDescription]); - } else { - [self removeTempFilePath:_videoWriter.outputURL.path]; - completion(); + PHPhotoLibrary* lib = [PHPhotoLibrary sharedPhotoLibrary]; + [lib performChanges:^{ + PHAssetCreationRequest* req = [PHAssetCreationRequest creationRequestForAsset]; + [req addResourceWithType:PHAssetResourceTypeVideo fileURL:_videoWriter.outputURL options:nil]; + + } completionHandler:^(BOOL success, NSError * _Nullable error) { + if(success) + { + NSLog(@"file saved!"); + } + else + { + NSLog(@"error \n %@",error); } }]; }