2

I've been researching about this issue for some time now, tried applying solutions on similar questions on stackoverflow but no luck so far.

My code:

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()
}

This is the line I get on the console:

< SKMetalLayer: 0x127eda5a0> : calling -display has no effect.

Mihriban Minaz
  • 3,043
  • 2
  • 32
  • 52
Tomer Ciucran
  • 199
  • 1
  • 10
  • 1
    Where is frame.size coming from? Also does your video have audio? Wondering if you can hear it but not see it. Also I would toss a log in playerItemDidReachEnd just to see if that ever triggers. – Skyler Lauren Mar 31 '16 at 20:35
  • @SkylerLauren Sorry for the late response! frame is SKNode.frame which is the size of the screen. the video doesn't have audio and yes the playerItemDidReachEnd gets triggered. – Tomer Ciucran Apr 08 '16 at 08:29
  • My best guess is your frame size is too small or off screen. – Skyler Lauren Apr 08 '16 at 11:46

0 Answers0