1

I am trying to configure a AVPlayerLayer, when I set it to the SCNMaterialProperty, it crash and get this error

-[MTLDebugBlitCommandEncoder generateMipmapsForTexture:]:790: failed assertion `tex mipmapLevelCount must be > 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()
}

Twice Edit

I saw this question AVPlayerLayer as SCNMaterial not rendered, audio playing fine. Then I tried to use SKVideoNode, but still have the same problem! Is that a bug? or?

Community
  • 1
  • 1
HaoDong
  • 339
  • 1
  • 10
  • Not sure if that's an Apple bug but I had the exception go away when I switched the `SCNSceneView` to the OpenGL ES rendering API. – Ortwin Gentz May 09 '17 at 09:31

0 Answers0