Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To save to the library once the assetWriter has finished recording the movie/capturing the image.</p> <p>Put this at the top above the implementation file *this is example of saving a video file but you could change that to save your image:</p> <pre><code>ALAssetsLibraryWriteVideoCompletionBlock _videoCompblock = ^(NSURL *assetURL, NSError *error){ if(assetURL){ NSLog(@"Saved to camera roll with Video AssetUrl : %@", [assetURL absoluteString]); NSError *error; NSFileManager *fileManager = [NSFileManager defaultManager]; NSDictionary *attributes = [fileManager attributesOfItemAtPath:[assetURL absoluteString] error:&amp;error]; if (attributes){ long fileSize = [[attributes objectForKey:NSFileSize] longValue];// unsigned long long NSLog(@"%d", fileSize); } }else if(error){ NSLog(@"The Error occured : %@", [error localizedDescription]); } </code></pre> <p>};</p> <p>Then you need a function that uses the above block - so when you capture session finishes recording have something like this:</p> <pre><code>-(void) stopRecording{ writing = NO; isRecording = NO; [audioInput markAsFinished];//if you have an audio writer stop it too [videoInput markAsFinished]; [assetWriter endSessionAtSourceTime:[frTimer currentTimeStamp]]; [assetWriter finishWriting]; finished = YES; [videoUtilities saveToCamera:[assetWriter outputURL]]; NSLog(@"%@", [[assetWriter outputURL] absoluteString]); </code></pre> <p>}</p> <p>which triggers the save to camera function which will look kinda like this:</p> <pre><code>+(void) saveToCamera:(NSURL *)urlPath{ ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; AVAsset *movFile = [AVURLAsset URLAssetWithURL:urlPath options:nil]; NSLog(@"Movie File %@", movFile); BOOL isSupported = [library videoAtPathIsCompatibleWithSavedPhotosAlbum:urlPath]; if(isSupported){ NSLog(@"IS SUPPORTED - SAVING TO CAMERA ROLL"); [library writeVideoAtPathToSavedPhotosAlbum:urlPath completionBlock:_videoCompblock]; } </code></pre> <p>}</p> <p>If you are trying to display the saved image realtime as you take it - you need to copy the UIImageData to a UIImage object when you take the photo - and assign that as the image for the UIImageView. Or you can just enumerate through the assetLibrary and pull it from there.</p> <p>Hope this helps,</p> <p>Cheers,</p> <p>Michael</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload