Help With Video

Hi,

I have a single view app. There are three nodes and I want to play a different video that’s saved in my project if the user taps on each of the nodes. I’m searching online and really coming up short.

Everything in the code is OK to detect which node the user taps, but I can’t get a video player to work. This almost works…once the node is tapped, it bring up a blank player screen…but the video doesn’t play.

Anyone have any other solutions?

if touchedNode.name == “MyNode1” {

        let videoURL = NSURL(fileURLWithPath: "MyVideoClip.mp4")
        let player = AVPlayer(URL: videoURL)
        let playerController = AVPlayerViewController()
        
        playerController.player = player
        self.view?.addSubview(playerController.view)
        playerController.view?.frame = (self.view?.frame)!
        
        player.play()
    }