xcodesprite-kitskvideonodesceneeditor

Is SKVideoNode compatible with Scene Editor?


I'm trying to add .mov files to my .sks file in scene editor. Is it possible? If so, how do you do it? This is as far as i got, am i going the right direction?

var videoNode: SKVideoNode?

func check() {
   videoNode = childNode(withName: "video") as? SKVideoNode
   videoNode = SKVideoNode(fileNamed: "FantasyBasketball-Score-Winning-4-20210112.mov") 
   print(videoNode)
}


override func sceneDidLoad() {
        check()
}

However, the videoNode returns nil after running.


Solution

  • I don't believe there is a Video node in the sks editor, therefore you'll have to add it in code. You could try

    func check() {
        let videoNode = SKVideoNode(fileNamed: "FantasyBasketball-Score-Winning-4-20210112.mov"
        addChild(videoNode)
        videoNode.play()
    }
    
    override func sceneDidLoad() {
            check()
    }