简体   繁体   English

如何在Android中使用Camera2在Framelayout上显示前置摄像头预览?

[英]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. 我正在使用一个应用程序,其中我使用tokbox进行视频通话,但是在显示“活动通话”屏幕之前,我需要向用户显示前置摄像头预览。 Using tokbox publisher we can't do that otherwise, the video will reach the end user before call accept. 使用Tokbox Publisher,我们不能这样做,否则视频将在呼叫接受之前到达最终用户。

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? 那么,如何使用Android的Camera2 API在帧布局中显示Front Camera Video预览(只是预览,我不需要任何捕捉或任何东西)?

您可以使用实例化发布者并使用其视图,而不是最初不发布到会话。

You can get a preview from the Publisher by calling Publisher.startPreview() . 您可以通过调用Publisher.startPreview()从Publisher获得预览。 This will start the camera and put it on the Publisher.getView() that you can put in your UI. 这将启动照相机并将其放置在您可以放入UI中的Publisher.getView()上。

Don't forget to do Publisher.destory() if you do this. 如果这样做,请不要忘记执行Publisher.destory()。 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. 起初我没有这样做,并且注意到在较旧的(非Camera2)设备上进行TokBox会话后,相机无法正确释放的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM