小编Tra*_*vis的帖子

仅当节点或摄像机移动时,SKVideoNode才在SCNScene中渲染

我正在使用一种非常简单的方法来设置SKVideoNode并将其通过几何体的漫反射内容放置在SCNNode中。当我这样做时,只有相机或节点移动时,纹理才能正确更新并正确显示视频。当两者都静止不动时,纹理将永远不会更新(例如甚至无法播放视频),但声音会播放。

显然,它仍在播放视频,但渲染不正确。我不知道为什么。

func setupAndPlay() {

    // create the asset & player and grab the dimensions
    let path = NSBundle.mainBundle().pathForResource("indycar", ofType: "m4v")!
    let asset = AVAsset(URL: NSURL(fileURLWithPath: path))
    let size = asset.tracksWithMediaType(AVMediaTypeVideo)[0].naturalSize

    let player = AVPlayer(playerItem: AVPlayerItem(asset: asset))

    // setup the video SKVideoNode
    let videoNode = SKVideoNode(AVPlayer: player)
    videoNode.size = size
    videoNode.position = CGPoint(x: size.width * 0.5, y: size.height * 0.5)

    // setup the SKScene that will house the video node
    let videoScene = SKScene(size: size)
    videoScene.addChild(videoNode)

    // create …
Run Code Online (Sandbox Code Playgroud)

avfoundation ios scenekit swift

2
推荐指数
1
解决办法
714
查看次数

标签 统计

avfoundation ×1

ios ×1

scenekit ×1

swift ×1