javascriptagora.ioscreensharingagora-web-sdk-ng

Agora Web SDK NG - stop screen share event exists?


currently I am using Agora Web SDK NG for video call implementation on web. I have one theoretical question. I started work on screen share. I will use example. I have video call members A and B. User A starts a screen share. Sharing is working fine, but problem occurs when user A wants to stop the screen share. User A click on standard Agora Stop share button which is shown from the screen share beginning..

After click, sharing is stopped but this change is not reflected to user B. The current video stream from user A stucked, because the stream was not unpublished. And this is my main problem. On user A side, I am not able to detect the button click on Agora standard stop share button. This button is outside of browser context so I am not able to just make selector and create button click event. If I would be able to detect this button click, I am able manually unpublish the stream. Do you know how to do it? I would expect some event handler something like this client.on("user-stop-share", handlerFunction). I am using Google Chrome browser. Thanks.


Solution

  • To close this bar you can use a track-ended event. Here the track is the instance of await AgoraRTC.createScreenVideoTrack.

     rtc.track.on('track-ended', () => {
          console.log('stopScreenSharing')
          })