Search code examples
agora.ioagora

Agora SDK - How to listen to screen share events?


I'm utilizing the Agora Flutter SDK to enable peer-to-peer video calls. Currently, peers can seamlessly initiate video calls with each other. However, I've encountered an issue where when peer1 shares his screen, the screen is displayed in the same camera window as the video stream for peer2. Unfortunately, peer2 does not receive any event when the video switches to the shared screen stream. This lack of feedback disrupts the user experience and poses a challenge for seamless interaction.

I plan to implement a mechanism to notify peer2 when the screen-sharing session begins and ends. This will ensure that peer2 is aware of the transition and can adapt accordingly. Additionally, I intend to provide custom controls specific to screen-sharing sessions for peer2. These controls will provide peer2 with the ability to interact with the shared screen, such as full-screen/hide the screen share, thereby enhancing their overall user experience.

I search across Agora Docs. But nothing relevant, there are many event for screen sharing fired to peer1 side, but nothing on peer2 side.


Solution

  • I've contacted agora support team with our private account regarding this and this was their response:

    I have received your inquiry about detecting the status when a remote user has shared the screen. With this, I would like to clarify that the event handlers/ callbacks did not have any support to detect wether a user was streaming the camera or sharing the screen.

    Additionally, both the camera video track and screen video tracks are both detected as video mediaTypes. There are no difference between them and it will require such mechanism as you have described.

    One way is to utilize Agora Signaling ( was RTM ) in order to send channel messages to other users. This in turn will serve as a notification as Signaling operates in real time.

    The workflow that They suggest is:

    Screen share user: Screen share button click -> Unpublish camera track -> Publish screen track -> send channel messages

    Other users: Receive screen video streams -> Receive channel messages -> Read channel messages -> User screen sharing identified -> Perform any intended action

    This process will require you to use 2 of our SDKs, ( Web Video SDK and Web Signaling SDK) , initialize both of their engines and then proceed with the workflow.

    enter image description here