2

我一直在研究这个问题一段时间,尝试在stackoverflow上应用类似问题的解决方案,但到目前为止没有运气。

我的代码:

override func didMoveToView(view: SKView) {
  if let path = NSBundle.mainBundle().pathForResource("stars", ofType: "mov") {
    let videoUrl = NSURL(fileURLWithPath: path)
    player = AVPlayer(URL: videoUrl)
    videoNode = SKVideoNode(AVPlayer: player)
    videoNode.size = frame.size
    videoNode.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
    addChild(videoNode)
    videoNode.play()
    NSNotificationCenter.defaultCenter().addObserver(self,
                                            selector: #selector(GameScene.playerItemDidReachEnd(_:)),
                                                name: AVPlayerItemDidPlayToEndTimeNotification,
                                              object: nil)
    setupView(true)
  } else { // Triggered if the video couldn't be found inside the project bundle
    print("Couldn't find the video")
  }
}

func playerItemDidReachEnd(notification: NSNotification) {
  player.seekToTime(kCMTimeZero)
  videoNode.play()
}

这是我在控制台上得到的行:

< SKMetalLayer: 0x127eda5a0> : 调用 -display 无效。

4

0 回答 0