如何在 table 视图中播放录制的视频输出 url

How to play recored video output url in the table view

我有一个 CollectionView 的图像,在下一个 ViewController 我正在使用 Av 捕获的会话录制视频并将其保存到移动文档目录中,然后我会回来到集合中,我正在重新加载集合视图,现在我想要在集合视图单元格中录制视频,而不使用任何 api。

我使用下面的代码将录制的视频保存在目录

'- (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];



         });
     }];
});

任何人都可以帮助解决此问题 problem.solution 感谢查看代码。我参考这个 https://github.com/shu223/SlowMotionVideoRecorder

录制了视频

1) 你可以通过获取你保存在文档目录下的视频的中心框来实现。

2) 可以将视频的中心帧图片保存到document目录下,这样就不用每次都生成

3) 在集合视图中显示视频缩略图。

参考此link获取视频帧:

Create thumbnail from a video url in IPhone SDK

编辑:

 NSString *videoPath = [videoURL path];
MPMoviePlayerViewController *videoPlayerView = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoPath]];
[self presentMoviePlayerViewControllerAnimated:videoPlayerView]; [videoPlayerView.moviePlayer play];