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); } }]; }