将AVPlayer设置为SCNMaterial.diffuse.contents时,获得“ [SceneKit]错误:”

时间:2018-07-11 09:23:15

标签: scenekit arkit

根据Apple的文档,SCNMaterial.diffuse.contents可以是AVPlayer。 在这种情况下,素材会出现在视频中。

一切似乎都很好,但是我得到了几个sceneKit错误日志:

 [SceneKit] Error: Could not get pixel buffer (CVPixelBufferRef)

下面是我的代码。将[_player play]移至viewWillAppear无济于事。

- (void)viewDidLoad {
    [super viewDidLoad];
    self.boxNode = [self.sceneView.scene.rootNode childNodeWithName:@"box" recursively:YES];
    NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/VRF_SuLie.MP4"];
    AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL fileURLWithPath:path]];
    AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
    _player = [AVPlayer playerWithPlayerItem:item];
    self.boxNode.geometry.firstMaterial.diffuse.contents = _player;
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [_player play];
}

如何避免此错误?

0 个答案:

没有答案