Get “[SceneKit] Error:” when set AVPlayer to SCNMaterial.diffuse.contents

耗尽温柔 提交于 2019-12-14 00:27:14

问题


According Apple's docs, SCNMaterial.diffuse.contents can be a AVPlayer. In this case material appear content of video.

Everything seems ok but I get several sceneKit error logs:

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

Below is my code. Move [_player play] to viewWillAppear does't help.

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

How to avoid this error?

来源:https://stackoverflow.com/questions/51281804/get-scenekit-error-when-set-avplayer-to-scnmaterial-diffuse-contents

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!