SCRecorder
SCRecorder copied to clipboard
Can't export to Camera roll
I can't export the video to the Camera roll.
Seems the output url is not pointing to the right merge file url.
[exportSession.outputUrl saveToCameraRollWithCompletion:^(NSString * _Nullable path, NSError * _Nullable error) {
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
if (error == nil) {
[[[UIAlertView alloc] initWithTitle:@"Saved to camera roll" message:@"" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
} else {
[[[UIAlertView alloc] initWithTitle:@"Failed to save" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
}];
Weird thing is that it works in the example project.
I had a similar issue, I was getting "Data Unavailable" error. Maybe the app permission for accessing the camera roll was disabled. I enabled it and everything worked fine.
In case anyone else is having this issue today, I would suggest using the PHPhotoLibrary to handling this use case.
- (void) saveToCameraRoll:(NSURL *)outputURL
{
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *changeRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:outputURL];
}
completionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog(@"save done");
}
else {
NSLog(@"something went wrong %@", error.localizedDescription);
}
}];
}