Loop Video KUDAN AR

144 views Asked by At

I need to Loop the video. How to get a callback when video has been ended. I need to loop it till user is tracking that video

private func addVideoNode(bundleFileName: String, forTrackableImage imageTrackable: ARImageTrackable?){
    // Initialise video node
    let videoNode = ARVideoNode(bundledFile: bundleFileName)
    // Add video node to image trackable
    imageTrackable?.world.addChild(videoNode)
    // Video scale
    let scale = Float(imageTrackable?.width ?? 0) / Float(videoNode?.videoTexture.width ?? 0)
    videoNode?.scale(byUniform: scale)
    videoNode?.visible = false
    videoNode?.play()
}
2

There are 2 answers

2
MultiColourPixel On BEST ANSWER

Register as a delegate on the ARPlayableTexture property of your video node.

The delegate gets a callback once the video is finished playing: https://www.kudan.eu/docs-reference/iOSDocs/protocol_a_r_playable_texture_delegate_01-p.html.

0
Nitesh On

Have to set delegate on videoNode like this.

    videoNode?.videoTextureMaterial.texture.delegate = self

Then

extension ARViewController: ARPlayableTextureDelegate{
    func playableTextureDidFinish(_ texture: ARPlayableTexture!) {
        videoNode?.play()
    }
}