Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions ASScreenRecorder/ASScreenRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import <AVFoundation/AVFoundation.h>
#import <QuartzCore/QuartzCore.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <Photos/Photos.h>

@interface ASScreenRecorder()
@property (strong, nonatomic) AVAssetWriter *videoWriter;
Expand Down Expand Up @@ -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);
}
}];
}
Expand Down