0
votes

i am using screensharing of vonage api in android studio java.I have followed their documentation,but the problem is:when i try to share screen it sends the video from camera instead of screen capturing.Here is code snippet,(in addition,do i need to use different API key,session id for screen sharing perpose different from video sharing 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);
}
1

1 Answers

1
votes

Finally I solved the issue:

Publisher.Builder mPublisherBuilder = new Publisher.Builder(MainActivity.this); //.build();
ScreenSharingCapturer screenCapturer = new ScreenSharingCapturer(MainActivity.this, mWebViewContainer);
mPublisherBuilder=mPublisherBuilder.capturer(screenCapturer);
mPublisher=mPublisherBuilder.build();

setCapturer was deprecated, so it wasn't setting the capturer from BaseVideoCapture.