OpenTok Android SDK 2.0, setPublishVideo(false) does not free the Camera. Any workarounds known?

ぐ巨炮叔叔 提交于 2019-12-14 02:06:01

问题


I'm trying to take a picture while there's an ongoing OpenTok video conference in an Android application. I use OpenTok SDK 2.0 for Android.

I tried to use publisher.setPublishVideo(false) to temporarily free the Camera so that the default Camera Activity can be used to take a picture. But looks like OpenTok does not free the Camera hardware.

As a workaround I tried using session.unpublish(publisher), which frees the Camera (and it also cuts the audio stream which is not desirable for me) but once I'm done with taking a picture, this time the a/v is not restored with session.publish(publisher).

Any help on this?


回答1:


Late response, but figured this may help for anyone who comes across the same issue.

My solution was to destroy capturer prior to starting intent to take picture

mPublisher.setPublishVideo(false);
BaseVideoCapturer bvc = mPublisher.getCapturer();
if(bvc != null){
    bvc.destroy();
}
//intent to start picture capture (Ex. ACTION_IMAGE_CAPTURE)

When you resume after taking the picture, you will need to initialize again

BaseVideoCapturer bvc = mPublisher.getCapturer();
if(bvc != null){
    if(bvc.isCaptureStarted() == false){
        bvc.init();
        bvc.startCapture();
        mPublisher.setPublishVideo(true);
    }           
}



回答2:


Have you ever tried publisher.onPause() and publisher.onResume(), this work for me.

Regards.




回答3:


I personally have never tried it, but using Android 2.0 beta 2, you might be able to use PublisherKit to accomplish something like that. There are methods like setRenderer(BaseVideoRenderer renderer) and setCapturer(BaseVideoCapturer capturer) that might allow you to programmatically free the camera on setPublishVideo( false )

Good luck!



来源:https://stackoverflow.com/questions/20285311/opentok-android-sdk-2-0-setpublishvideofalse-does-not-free-the-camera-any-wo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!