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.