简体   繁体   English

SceneKit AVPlayer 仅播放音频

[英]SceneKit AVPlayer only audio is playing

I am trying to play a video in SceneKit .我正在尝试在SceneKit播放视频。 I can hear the audio but video is not rendering.我可以听到音频,但视频无法呈现。 The way i am using the scene is as follows.我使用场景的方式如下。 Please help.请帮忙。

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

You need to use a real iPhone not simulator to enjoy.您需要使用真正的 iPhone 而不是模拟器来享受。

Another reason is the shading in the material panel should not be physical based.另一个原因是材质面板中的阴影不应该是基于物理的。 You may try Blinn.你可以试试布林。 The code has no problem.代码没有问题。

If using a physical based, you have to add an extra light to make it work.如果使用基于物理的,则必须添加额外的灯光才能使其工作。

you can keep PBR and get glass reflections with a non-rough material.您可以保持 PBR 并使用非粗糙材料获得玻璃反射。 use the emission instead of diffuse for the the video though对视频使用emission而不是diffuse

plane.geometry.firstMaterial.emission.contents = player

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM