根据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];
}
如何避免此错误?