首页 > 解决方案 > SceneKit AVPlayer 仅播放音频

问题描述

我正在尝试播放视频SceneKit。我可以听到音频但视频未呈现。我使用场景的方式如下。请帮忙。

SCNScene *scene = [SCNScene sceneNamed:@"art.scnassets/plane.scn"];
SCNNode *plane = [scene.rootNode childNodeWithName:@"plane" recursively:YES];

AVPlayer *player = [AVPlayer playerWithURL:[NSURL URLWithString:@"https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_5mb.mp4"]];
plane.geometry.firstMaterial.diffuse.contents = player;
[player play];

SCNView *scnView = (SCNView *)self.view;
scnView.scene = scene;
scnView.allowsCameraControl = YES;
scnView.showsStatistics = YES;
scnView.backgroundColor = [UIColor blackColor];

标签: iosobjective-ciphonescenekitavplayer

解决方案


您需要使用真正的 iPhone 而不是模拟器才能享受。

另一个原因是材质面板中的阴影不应该是基于物理的。你可以试试布林。代码没有问题。

如果使用基于物理的,则必须添加额外的灯光才能使其工作。


推荐阅读