2

I've just ported the game I'm working on in Sprite Kit to the released version of Xcode 7 & got everything updated except I can't play my video's using SKVideoNodes. The code runs, but just plays audio & not video in Xcode 7. Video plays fine with the same code in Xcode 6.4.

I build a sample project using the Sprite Kit Game template. The following code will play a video (assuming the video is in the project) when you replace the GameScene class in the gameScene.swift file with this code. But if you past this into a Sprite Kit Game template from Xcode 7 it will only play audio.

Hope someone can help with this, I've spend hours but no luck.

//  GameScene.swift
//  VideoNode


import SpriteKit
import AVFoundation

class GameScene: SKScene {


    // Video Sprite Node
    var player:AVPlayer?
    var videoNode:SKVideoNode?

    override func didMoveToView(view: SKView) {
        /* Setup your scene here */

        // play video

        let urlStr = NSBundle.mainBundle().pathForResource("sampleVideo", 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: 200.0, height: 150.0)
        videoNode?.zPosition = 1

        addChild(videoNode!)
        videoNode!.play()
    }
}
pokeyOne
  • 312
  • 1
  • 2
  • 12
ronsinda
  • 139
  • 1
  • 5
  • 2
    Update to post: I found the problem. It seems to be a Simulator issue. The Xcode 7.0 simulator was just playing audio & not showing video. When I loaded the code on my iPad or iPhone, it worked fine. Seems to be a bug in Apples new Xcode 7.0 simulator. – ronsinda Sep 20 '15 at 20:23

0 Answers0