2

Basically SKVideoNode will not respect AVPlayer's rate.

By default, SKVideoNode has no way of controlling playback rate. However, the SKVideoNode can be initialized with an AVPlayer (which itself contains an AVPlayerItem). This AVPlayer has a property rate which can vary from 0 to 2 (1 is normal speed). There is also the method setRate:time:atHostTime:.

So the rate doesn't work. Have you had the same problem?. If there is no way to resolve this? is there another way to play a video and change the frame rate in a SKScene?

func setupVideo() {
    // play video
    let urlStr = NSBundle.mainBundle().pathForResource("sample", ofType: "mp4")
    let url = NSURL(fileURLWithPath: urlStr!)

    player = AVPlayer(URL: url)

    videoNode = SKVideoNode(AVPlayer: player!)
    videoNode?.position = CGPointMake(frame.size.width/2, frame.size.height/2)
    videoNode?.size = CGSize(width: frame.size.width, height: frame.size.height)
    videoNode?.zPosition = 1
    addChild(videoNode!)

    player!.rate = 0.25
    videoNode!.play()


}

It doesn't matter where I add player!.rate = 0.25, it never changes.

utiq
  • 1,342
  • 2
  • 17
  • 33

1 Answers1

2

-- UPDATE This was an Apple API issue, it was fixed in iOS 10 version.

utiq
  • 1,342
  • 2
  • 17
  • 33