SCNMaterialProperty呈现AVPlayerLayer崩溃错误

时间:2017-02-17 10:41:30

标签: ios scenekit metal

我正在尝试配置AVPlayerLayer,当我将其设置为SCNMaterialProperty时,它会崩溃并出现此错误

- [MTLDebugBlitCommandEncoder generateMipmapsForTexture:]:790:断言失败`tex mipmapLevelCount必须是> 1'

private func configurePlayer(_ movieURL: URL) -> AVPlayerLayer {
    let player = AVPlayer(url: movieURL)
    player.actionAtItemEnd = .none

    NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidReachEnd(_:)), name: Notification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem)

    player.play()

    let playerLayer = AVPlayerLayer()
    playerLayer.player = player
    playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
    playerLayer.frame = CGRect(x: 0, y: 0, width: 600, height: 800)

    let backgroundLayer = CALayer()
    backgroundLayer.backgroundColor = UIColor.black.cgColor
    backgroundLayer.frame = CGRect(x: 0, y: 0, width: 600, height: 800)
    backgroundLayer.addSublayer(playerLayer)

    photoFrameNode.geometry?.material(named: "Material")?.diffuse.contents = backgroundLayer
    return playerLayer
}

private func setUpMovie() {
    SCNTransaction.begin()
    SCNTransaction.animationDuration = 1.0
    scnView.isPlaying = true
    scnView.loops = true
    scnView.scene?.setAttribute(7.33, forKey: SCNScene.Attribute.endTime.rawValue)
    let path = Bundle.main.path(forResource: "movie1", ofType: "mov")!
    let url = URL(fileURLWithPath: path)
    _ = configurePlayer(url)
    SCNTransaction.commit()
}

两次修改

我看到了这个问题AVPlayerLayer as SCNMaterial not rendered, audio playing fine。然后我尝试使用SKVideoNode,但仍然有同样的问题!那是一个错误吗?或?

0 个答案:

没有答案