VideoRenderer not working

0 votes
asked Feb 3, 2020 by moeindevelop (160 points)

I implemented the Hello AR video with my app, everything works just fine but when it comes to scanning the targets, the video loads but I just hear the noise of the video:

here is my ARVideo class:

import Foundation
import EasyARSwift
class ARVideo {
    private var player: VideoPlayer? = nil
    private var prepared: Bool = false
    private var found: Bool = false
    private var _path: String = ""
    
    init() {
        player = VideoPlayer()
        prepared = false
        found = false
    }
    
    func openNormalVideoFromAssets(path: String?, textID: UInt32, scheduler: DelayedCallbackScheduler){
        self._path = path ?? ""
        player?.setRenderTexture(TextureId.fromPointer(OpaquePointer(UnsafeRawPointer(bitPattern: Int(textID))!)))
        player?.setVideoType(.Normal)
        weak var weak_self: ARVideo? = self
        player?.open(_path, .Assets, scheduler, { (status) in
            weak_self?.setVideoStatus(status: status)
        })
    }
    
    func openTransparentVideFromAssets(path: String?, textID: UInt32, scheduler: DelayedCallbackScheduler){
        self._path = path ?? ""
        player?.setRenderTexture(TextureId.fromPointer(OpaquePointer(UnsafeRawPointer(bitPattern: Int(textID))!)))
        player?.setVideoType(.TransparentSideBySide)
        weak var weak_self: ARVideo? = self
        player?.open(_path, .Assets, scheduler, { (status) in
            weak_self?.setVideoStatus(status: status)
        })
    }
    
    func openStreamingNormalVideo(url: String?, textID: UInt32, scheduler: DelayedCallbackScheduler){
        self._path = url ?? ""
        player!.setRenderTexture(TextureId.fromPointer(OpaquePointer(UnsafeRawPointer(bitPattern: Int(textID))!)))
        player!.setVideoType(.Normal)
        weak var weak_self: ARVideo? = self
        player!.open(_path, .Absolute, scheduler, { (status) in
            weak_self?.setVideoStatus(status: status)
        })
    }
    
    func openStreamingTransparentVideo(url: String?, textID: UInt32, scheduler: DelayedCallbackScheduler){
        self._path = url ?? ""
        player!.setRenderTexture(TextureId.fromPointer(OpaquePointer(UnsafeRawPointer(bitPattern: Int(textID))!)))
        player!.setVideoType(.TransparentSideBySide)
        weak var weak_self: ARVideo? = self
        player!.open(_path, .Absolute, scheduler, { (status) in
            weak_self?.setVideoStatus(status: status)
        })
    }
    
    func setVideoStatus(status: VideoStatus){
        print("Video path: \(_path) with status:\(status)")
        if (status == .Ready) {
            prepared = true
            if(found){
                player!.play()
            }
        }else if (status == .Completed){
            if(found){
                player!.play()
            }
        }
    }
    
    func onFound(){
        found = true
        if(prepared){
            player!.play()
        }
    }
    
    func onLost(){
        found = false
        if (prepared) {
            player!.pause()
        }
    }
    
    func update(){
        player!.updateFrame()
    }
    
    func isRenderTextureAvailable() -> Bool {
        return player!.isRenderTextureAvailable()
    }
}

Please log in or register to answer this question.

Welcome to EasyAR SDK Q&A, where you can ask questions and receive answers from other members of the community.
...