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

StackOverflow https://stackoverflow.com/questions/20285311

  •  06-08-2022
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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);
    }           
}

OTHER TIPS

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

Regards.

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top