2016-08-03 74 views
1

我有一个CollectionView的图像,并在下一个ViewController我录制的视频使用Av捕获的会话,我将它保存到移动文档目录,然后我来了回到集合,我现在重新加载集合视图我想在集合视图单元格中使用任何api录制视频。如何在表视图中播放recored视频输出url

我用下面的代码来保存视频条记录在目录

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

+0

@Suraj sukale –

+0

您在 “cellForItemsAtIndex” 做到这一点,你可以给任何解决方案方法。为视频解析项目出列视频单元格。 –

+0

你可以建议我一些链接或一些代码,请 –

回答

0

1)您可以通过获取存储在文档目录中的视频的中心帧来实现。

2)您可以将视频的中央帧图像存储到文档目录,以便您不必每次都生成。

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

请参阅此链接的视频获取帧:

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]; 
+0

我已经保存在文档目录中的图像,我在设备中找到视频,我希望视频从第二个vc传递到第一个vc我我收集收集视图 –

+0

在存储视频路径的NSString类型的第1个vc内创建一个属性。当你从第二个vc通过时,在那个属性中设置值。 –

+0

shareview.videoPath = yourvideoPath; –