当在报纸上检测到图像时,我正在播放视频,但是,即使该图像不再可用,该视频仍会继续播放。
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
videoNode.pause()
} // i tried this function but it stops as soon as it moves
这就是我现在正在做的
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
let node = SCNNode()
if let imageAnchor = anchor as? ARImageAnchor {
let videoNode = SKVideoNode(fileNamed: "HarryPotterVideo.mp4")
videoNode.play()
let videoScene = SKScene(size: CGSize(width: 480, height: 360))
videoNode.position = CGPoint(x: videoScene.size.width/2, y: videoScene.size.height/2)
videoNode.yScale = -1.0
videoScene.addChild(videoNode)
let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height)
plane.firstMaterial?.diffuse.contents = videoScene
let planeNode = SCNNode(geometry: plane)
planeNode.eulerAngles.x = -.pi/2
node.addChildNode(planeNode)
if(videoScene.view?.scene?.isHidden == true) {
print("Out of view")
}
}
return node
}
现在,我正尝试在isHidden
上通过scene
暂停它,但是它也不起作用