Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated to support new library manager (Using the Photos framework) #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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