Sample code for Screen sharing on android using "com.azure.android:azure-communication-calling:2.6.0-beta.5"

Pawan Yadav 0 Reputation points
2024-01-03T05:19:12.6666667+00:00

Hi,

I am implementing Video calling and screen sharing app  using video calling library in Android app. I am using "com.azure.android:azure-communication-calling:2.6.0-beta.5" library for implement it.

I followed following resource for implementing video calling functionality.

https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/voice-video-calling/get-started-with-video-calling?pivots=platform-android

Video calling functionality is implemented and working but unable to share screen. I visted microsoft learning resource there mentioned screen share is supported by the library. I did not find and sample code for screen sharing on Android app. How can i implement it on Android or IOS. it is better if i will get sample code for screen sharing on Android and IOS. So requesting to provide sample code for Android and IOS or guidance for it.

Thanks

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
1,234 questions
{count} votes

2 answers

Sort by: Most helpful
  1. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2024-01-04T01:05:44.8066667+00:00

    @Pawan Yadav Regarding your question, the Azure Communication Services calling library does support screen sharing. However, the library does not provide a built-in UI for screen sharing. You will need to implement the UI for screen sharing yourself.

    Here is an example of how you can implement screen sharing using the Azure Communication Services calling library in Android:

    1. First, you need to create a LocalVideoStream object for the screen sharing stream. You can do this by calling the DeviceManager.createScreenSharingStream() method.
    DeviceManager deviceManager = callClient.getDeviceManager();
    LocalVideoStream screenSharingStream = deviceManager.createScreenSharingStream();
    
    
    
    1. Next, you need to add the screen sharing stream to the call. You can do this by calling the Call.startScreenSharing() method.
    call.startScreenSharing(screenSharingStream, new StartCallOptions(), new RemoteVideoStreamAddedListener() {
        @Override
        public void onRemoteVideoStreamAdded(RemoteVideoStreamAddedEvent remoteVideoStreamAddedEvent) {
            // Handle the remote video stream added event
        }
    });
    
    1. Finally, you need to render the screen sharing stream on the UI. You can do this by creating a VideoStreamRendererView object and attaching it to the RemoteVideoStream object.
    RemoteVideoStream remoteVideoStream = remoteVideoStreamAddedEvent.getRemoteVideoStream();
    VideoStreamRendererView videoStreamRendererView = new VideoStreamRendererView(context);
    remoteVideoStream.addRenderer(new VideoStreamRenderer(videoStreamRendererView, ScalingMode.Crop));
    
    

    Please note that this is just an example and you will need to modify it to fit your specific use case. Also, make sure to handle any errors that may occur during the screen sharing process.


  2. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2024-02-05T02:07:34.5333333+00:00

    @Pawan Yadav I apologize for the confusion. The createScreenSharingStream() method is not available in the DeviceManager class of the com.azure.android:azure-communication-calling:2.6.0-beta.5 library. This method is available in the com.azure.android:azure-communication-calling-screen-share:1.0.0-beta.5 library. To use screen sharing in your Android app, you need to add the following dependency to your app's build.gradle file:

    implementation 'com.azure.android:azure-communication-calling-screen-share:1.0.0-beta.5'
    

    After adding the dependency, you can create a LocalVideoStream object for the screen sharing stream by calling the DeviceManager.createScreenSharingStream() method:

    DeviceManager deviceManager = callClient.getDeviceManager();
    LocalVideoStream screenSharingStream = deviceManager.createScreenSharingStream();
    

    Please note that the com.azure.android:azure-communication-calling-screen-share:1.0.0-beta.5 library is currently in beta and subject to change.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.