I have a CollectionView
with images and in the next ViewController
I am recording a video using Av captured sessions and i am saving it in to the mobile document directory,Then i am coming back to the collection and i am reloading the collection view now i want the recored video in the collection view cell with out using any api.
I used the below code to save the recored video in the directory
'- (void)saveRecordedFile:(NSURL *)recordedFile {
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
[assetLibrary writeVideoAtPathToSavedPhotosAlbum:recordedFile
completionBlock:
^(NSURL *assetURL, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
NSString *title;
NSString *message;
if (error != nil) {
title = @"Failed to save video";
message = [error localizedDescription];
}
else {
title = @"Saved!";
message = nil;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
UIStoryboard *storybord=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
shareViewController *shareview=[storybord instantiateViewControllerWithIdentifier:@"share"];
[self presentViewController:shareview animated:YES completion:nil];
});
}];
});
can any body help out to solve this problem.solution view code is appreciated. i recored video by referring this https://github.com/shu223/SlowMotionVideoRecorder
1) You can achieve it by getting the center frame of the video which you have stored in the document directory.
2) You can store the center frame image of the video to document directory so that you don't have to generate everytime.
3) Display video thumbnail inside collectionview.
Refer this link for get frame of the video :
Create thumbnail from a video url in IPhone SDK
EDIT:
NSString *videoPath = [videoURL path];
MPMoviePlayerViewController *videoPlayerView = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoPath]];
[self presentMoviePlayerViewControllerAnimated:videoPlayerView]; [videoPlayerView.moviePlayer play];