我在 android studio java 中使用 vonage api 的屏幕共享。我遵循了他们的文档,但问题是:当我尝试共享屏幕时,它从相机发送视频而不是屏幕捕获。这是代码片段,(在另外,我是否需要使用不同的 API 密钥、会话 ID 进行屏幕共享,与视频共享 api 不同)
@Override
public void onConnected(Session session) {
Log.d(TAG, "onConnected: Connected to session " + session.getSessionId());
mPublisher = new Publisher.Builder(MainActivity.this).name("publisher").build();
mPublisher.setPublisherListener(this);
mPublisher.setPublisherVideoType(PublisherKit.PublisherKitVideoType.PublisherKitVideoTypeScreen);
mPublisher.setAudioFallbackEnabled(false);
ScreenSharingCapturer screenCapturer = new ScreenSharingCapturer(MainActivity.this, mWebViewContainer);
mPublisher.setCapturer(screenCapturer);
mWebViewContainer.setWebViewClient(new WebViewClient());
WebSettings webSettings = mWebViewContainer.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebViewContainer.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
mWebViewContainer.loadUrl("http://www.tokbox.com");
mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
mPublisherViewContainer.addView(mPublisher.getView());
mSession.publish(mPublisher);
}
答案 0 :(得分:1)
我终于解决了这个问题:
Publisher.Builder mPublisherBuilder = new Publisher.Builder(MainActivity.this); //.build();
ScreenSharingCapturer screenCapturer = new ScreenSharingCapturer(MainActivity.this, mWebViewContainer);
mPublisherBuilder=mPublisherBuilder.capturer(screenCapturer);
mPublisher=mPublisherBuilder.build();
setCapturer
已被弃用,因此它不会从 BaseVideoCapture
设置捕获器。