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?