Siraj Sumra
Siraj Sumra

Reputation: 964

How to show Front Camera Preview on Framelayout using Camera2 in Android?

I am working in one application, In which I am using tokbox for the video calling, But before displaying the Active call screen, I need to show the front camera preview to the user. Using tokbox publisher we can't do that otherwise, the video will reach the end user before call accept.

So How can we show Front Camera Video preview(Just the preview, I don't need any capturing or anything) in the framelayout using Camera2 API of Android?

Upvotes: 0

Views: 368

Answers (2)

Lance Johnson
Lance Johnson

Reputation: 1276

You can get a preview from the Publisher by calling Publisher.startPreview(). This will start the camera and put it on the Publisher.getView() that you can put in your UI.

Don't forget to do Publisher.destory() if you do this. I didn't do that at first and noticed issues of the camera not being released correctly after TokBox sessions on older (non-Camera2) devices.

Upvotes: 1

Jaideep Shah
Jaideep Shah

Reputation: 146

You can use instantiate the publisher and use it's view, and not publish to the session initially.

Upvotes: 0

Related Questions