VuforiaSampleSwift icon indicating copy to clipboard operation
VuforiaSampleSwift copied to clipboard

Playing video

Open ghost opened this issue 8 years ago • 8 comments

Hey, lovely project, have been using it to work with Vuforia for a few weeks. Do you have any guidelines on how this project could be used to display a video instead of where you'd display a SCNode? Vuforia has a sample for playing video but it's a bit over my head, maybe you could give me some directions. Thanks!

ghost avatar Oct 05 '16 14:10 ghost

Yes i agree. I'm trying to do this and would like some advice if possible :) This project has been really helpful!

markleeyw avatar Oct 14 '16 00:10 markleeyw

@Angryhead

I fixes minor issue in 32ec7d8f. So, if you are using iOS9, You can display video using SKVideoNode. But iOS10 not work PrefersOpenGL. it seems to be used Metal for rendering SKVideoNode in iOS10.


fileprivate func createStonesScene(with view: VuforiaEAGLView) -> SCNScene {
        let scene = SCNScene()

        let lightNode = SCNNode()
        lightNode.light = SCNLight()
        lightNode.light?.type = .omni
        lightNode.light?.color = UIColor.lightGray
        lightNode.position = SCNVector3(x:0, y:10, z:10)
        scene.rootNode.addChildNode(lightNode)

        let ambientLightNode = SCNNode()
        ambientLightNode.light = SCNLight()
        ambientLightNode.light?.type = .ambient
        ambientLightNode.light?.color = UIColor.darkGray
        scene.rootNode.addChildNode(ambientLightNode)

        let videoWidth: CGFloat = 1280
        let videoHeight: CGFloat = 720

        let urlStr = Bundle.main.path(forResource: "sample", ofType: "mov")
        let url = URL(fileURLWithPath: urlStr!)

        let asset = AVURLAsset(url: url, options: nil)
        let playerItem = AVPlayerItem(asset: asset)
        let player = AVPlayer(playerItem: playerItem)

        let videoNode = SKVideoNode(avPlayer: player)
        videoNode.position = CGPoint(x: videoWidth/2.0, y: videoHeight/2.0)
        videoNode.yScale = -1.0

        let sprite = SKScene(size: CGSize(width: videoWidth, height: videoHeight))
        videoNode.size.width = sprite.size.width
        videoNode.size.height = sprite.size.height
        sprite.addChild(videoNode)

        let planeNode = SCNNode()
        planeNode.name = "plane"
        planeNode.geometry = SCNPlane(width: 247.0/view.objectScale, height: 173.0/view.objectScale)
        planeNode.position = SCNVector3Make(0, 0, -2)
        planeNode.transform = SCNMatrix4MakeScale(1.0, 9.0/16.0, 1.0)
        let planeMaterial = SCNMaterial()
        planeMaterial.diffuse.contents = sprite
        planeNode.geometry?.firstMaterial = planeMaterial
        scene.rootNode.addChildNode(planeNode)
        videoNode.play()
}

yshrkt avatar Oct 14 '16 05:10 yshrkt

for iOS 10 as mentioned cannot see.

Any advice how to slove this as most user now as slowly moving to iOS 10?

Thank you!

2016-10-16 17:40:32.786630 VuforiaSampleSwift[502:60027] Created new image data buffer @ 0x10ae7c000 w/ 1382400 bytes stones scene Failed to create IOSurface image (texture) after EAGLView renderFrameVuforia() glError (0x506) after EAGLView renderFrameVuforia() glError (0x506)

markleeyw avatar Oct 16 '16 09:10 markleeyw

@markleeyw I'm trying to use Vuforia with Metal instead of OpenGLES. But it does not work well now...

yshrkt avatar Oct 17 '16 06:10 yshrkt

Thank you. Hope there is some update soon :)

markleeyw avatar Oct 17 '16 06:10 markleeyw

Hey @yshrkt - any news on that update? 😃

byroncoetsee avatar Nov 17 '16 18:11 byroncoetsee

Any update ? :)

markleeyw avatar Dec 09 '16 08:12 markleeyw

Any update :)

markleeyw avatar Jan 16 '17 11:01 markleeyw