Hi I'm trying to play video on an SKVideoNode in swift this is my code that works but it only plays once if i click on VideoSprite it doesn't play but dose print "we Clicked the video" I've searched but can't seem to find an answer thanks for looking
import SpriteKit
import AVFoundation
class GameScene: SKScene
{
var VideoSprite = SKVideoNode()
override func didMoveToView(view: SKView)
{
LoadVideo("9.mp4")
}
func LoadVideo(FileToPlay:String)
{
VideoSprite = SKVideoNode (videoFileNamed:FileToPlay)
VideoSprite.position = CGPointMake(size.width/2, size.height/2);
VideoSprite.name = "VideoSprite"
VideoSprite.zPosition = 2
addChild(VideoSprite)
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)
{
for touch in (touches as! Set<UITouch>)
{
var touch: UITouch = touches.first as! UITouch
var location = touch.locationInNode(self)
var node = self.nodeAtPoint(location)
if (node.name == "VideoSprite")
{
println("we Clicked the video")
VideoSprite.play()
}
}
}
}
Hi I think I've cracked it i add another videoSKnode on top and rename it so the user can't click on the original video then after a delay i remove it this delay needs to be the time the video runs i use a cool function for delay i found on the internet can't remember where from so thanks to who ever wrote it i hope this might help somebody else i tried the paused bool in the update function but no luck?