in Education by
I've followed along with this excellent tutorial from Yuma and have something working. Below is the code that I'm using in my viewcontroller import UIKit import SceneKit import ARKit import AVFoundation import SpriteKit class ViewController: UIViewController, ARSCNViewDelegate { @IBOutlet var sceneView: ARSCNView! override func viewDidLoad() { super.viewDidLoad() // Set the view's delegate sceneView.delegate = self // Show statistics such as fps and timing information sceneView.showsStatistics = true // Create a new scene let scene = SCNScene(named: "art.scnassets/notebook.scn")! // Set the scene to the view sceneView.scene = scene } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Create a session configuration let configuration = ARImageTrackingConfiguration() guard let arImages = ARReferenceImage.referenceImages(inGroupNamed: "AR Resources", bundle: nil) else { return } configuration.trackingImages = arImages // Run the view's session sceneView.session.run(configuration) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) // Pause the view's session sceneView.session.pause() } func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { guard anchor is ARImageAnchor else { return } // Amy Image recognition guard let amyContainer = sceneView.scene.rootNode.childNode(withName: "amy", recursively: false) else { return } amyContainer.removeFromParentNode() node.addChildNode(amyContainer) amyContainer.isHidden = false // Video let videoURL = Bundle.main.url(forResource: "video", withExtension: "mp4")! let videoPlayer = AVPlayer(url: videoURL) let videoScene = SKScene(size: CGSize(width: 900.0, height: 1400.0)) let videoNode = SKVideoNode(avPlayer: videoPlayer) videoNode.position = CGPoint(x: videoScene.size.width / 2, y: videoScene.size.height / 2) videoNode.size = videoScene.size videoNode.yScale = -1 videoNode.play() videoScene.addChild(videoNode) guard let video = amyContainer.childNode(withName: "video", recursively: true) else { return } video.geometry?.firstMaterial?.diffuse.contents = videoScene } } When I use the video that was supplied as part of the tutorial everything works perfectly, but when I try and include a video that I've created I only get a white box over the target image, but no video. I've tripled checked the name, I've tried to export the video with the exact same dimensions all with no luck. I've tested uploading a new version of the video that does work as a different file name and changed the names and it works, so I have to assume it's the .mp4 that I'm producing which is the problem. Are there particular rules/settings that are required for mp4's for this kind of approach, is there a setting in premiere pro or Handbrake that I can use? Or how can I debug any internal errors that are happening through Xcode itself? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Could be because your video size is big. You would need to wait first for AVPlayer to be ready before trying to play your video class ViewController: UIViewController, ARSCNViewDelegate { @IBOutlet var sceneView: ARSCNView! var observer: NSKeyValueObservation? var videoNode: SKVideoNode? override func viewDidLoad() { super.viewDidLoad() // Set the view's delegate sceneView.delegate = self // Show statistics such as fps and timing information sceneView.showsStatistics = true // Create a new scene let scene = SCNScene(named: "art.scnassets/notebook.scn")! // Set the scene to the view sceneView.scene = scene } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Create a session configuration let configuration = ARImageTrackingConfiguration() guard let arImages = ARReferenceImage.referenceImages(inGroupNamed: "AR Resources", bundle: nil) else { return } configuration.trackingImages = arImages // Run the view's session sceneView.session.run(configuration) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) // Pause the view's session sceneView.session.pause() } func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { guard anchor is ARImageAnchor else { return } // Amy Image recognition guard let amyContainer = sceneView.scene.rootNode.childNode(withName: "amy", recursively: false) else { return } amyContainer.removeFromParentNode() node.addChildNode(amyContainer) amyContainer.isHidden = false let videoPlayer = self.createAVPlayer() let videoScene = SKScene(size: CGSize(width: 900.0, height: 1400.0)) self.videoNode = SKVideoNode(avPlayer: videoPlayer) self.videoNode?.position = CGPoint(x: videoScene.size.width / 2, y: videoScene.size.height / 2) self.videoNode?.size = videoScene.size self.videoNode?.yScale = -1 videoScene.addChild(self.videoNode!) guard let video = amyContainer.childNode(withName: "video", recursively: true) else { return } video.geometry?.firstMaterial?.diffuse.contents = videoScene } func createAVPlayer() -> AVPlayer { let videoURL = Bundle.main.url(forResource: "video", withExtension: "mp4")! let asset = AVAsset(url: videoURL) let assetKeys = [ "playable", "hasProtectedContent" ] let playerItem = AVPlayerItem(asset: asset, automaticallyLoadedAssetKeys: assetKeys) self.observer = playerItem.observe(\.status, options: [.new, .old], changeHandler: { (playerItem, change) in if playerItem.status == .readyToPlay { self.videoNode?.play() // Only play when Its ready } }) return AVPlayer(playerItem: playerItem) } }

Related questions

0 votes
    Which animation is used to repeat the animation? Ctrl+Play Ctrl+Enter Ctrl+Loop Ctrl+Loop Playback pls help anyone Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Which animation is used to repeat the animation? Ctrl+Play Ctrl+Enter Ctrl+Loop Ctrl+Loop Playback pls help anyone Select the correct answer from above options...
asked Dec 18, 2021 in Education by JackTerrance
0 votes
    Explain : Opposition parties held a meeting in Mumbai to resist the Ruling party. Will take up the issue of farmers? Please answer the above question....
asked Aug 14, 2022 in Education by JackTerrance
0 votes
    Explain the following statements by giving reasons : Political parties can concentrate on one particular issue. Please answer the above question....
asked Aug 14, 2022 in Education by JackTerrance
0 votes
    Describe the Kashmir issue between India and Pakistan. Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    I'm working on migrating/rewriting some Java generics in C#. I'm getting an error that I don't ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    Has any else experienced when logging into to sitecore it says too many users are logged but when you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I'm working on migrating/rewriting some Java generics in C#. I'm getting an error that I don't ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I'm working on migrating/rewriting some Java generics in C#. I'm getting an error that I don't ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am trying to insatll Python Boilerpipe in my Ubuntu 14. It fails with the following error: Traceback ( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    Facing issue in session with the upgrade of my application to Spring 4.1.9 and Hibernate 4.3.11.. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I have loop inside loop like this: var len = bolumlerUnique.length; function bolumleriGonder() { for (i ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    I have loop inside loop like this: var len = bolumlerUnique.length; function bolumleriGonder() { for (i ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I have loop inside loop like this: var len = bolumlerUnique.length; function bolumleriGonder() { for (i ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have the following SQL query: query_string = "SELECT sum(unmatched), " \ "TIMESTAMP WITH TIME ZONE ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
...