Handling the active-share-change event when one joins the channel after someone shared the screen

Description
when one person is sharing the screen and some other participant either joins the channel after that or refreshes their screen then the active-share-change event is coming even before the user-added event, and because of that, the canvas element for the screen-share is not in the DOM at that moment, because in our UI the canvas element for the screen share is added in each participants’ card which populates after getting the user-added event.

I have added a screenshot of the console where the first console is of active-share-screen event and then user-added and user-updated.

Which Web Video SDK version?
Using 1.3.0 Web video SDK version

Screenshots

Device (please complete the following information):

  • Device: Macbook Air
  • OS: macOS 12.4 (Monterey)
  • Browser: All browsers

Hey @vk-jangid

Thanks for your feedback.

In the Video SDK Web, we provide an API named getActiveShareUserId, when a user joined after someone has started sharing, you can get the shared user via this API, if the value is not null, then use the startShareView(canvas,userId) to render the shared content.

Thanks
Vic

Understood, will try this.

One more issue I am facing currently with the startAudio used with speakerOnly option.
In this case, what is happening is that after calling startAudio with speakerOnly being true then I am not able to start the microphone afterward.
I tried calling unmuteAudio after that and startAudio with no parameter but still the mic is not starting.

Hey @vk-jangid

If you specified speakerOnly option in startAudio method, you are unable to connect the microphone until stop the audio explicitly via stopAudio and re-connect the audio without the speakerOnly option via startAudio.

Thanks
Vic

Oh, Ok.
I will try this as well, but I would suggest adding these changes in the documentation as well.

One more issue is happening that when I am calling the startAudio with speakerOnly option and then i am stopping the audio and again starting the audio by using stopAudio and startAudio (without speakerOnly option) in the case where the microphone permission is not given at the browser level then sometime ‘USER_FORBIDDEN_MICROPHONE’ error is coming but sometimes it doesn’t.
Why is that?
I tried this in the sample app by calling the startAudio function with speakerOnly parameter being true for once and after that always false but the same issue is there as well.

Hey @vk-jangid

What do you mean when you mentioned ’ the microphone permission is not given at the browser level '? Does the permission request dialog not appear?

If the permission request dialog pops but the user doesn’t grant the permission(Click the ‘block’ or doesn’t click anything), the Video SDK cannot obtain access to the microphone, then will return ‘USER_FORBIDDEN_MICROPHONE’ error.

And what browser are you using? Chrome, Firefox, Safari, or Edge?

Thanks
Vic

I meant that I blocked the microphone permission, and then when I call the startAudio function then sometime it is throwing the error but sometimes it doesn’t.

It’s happening only in the case when at first I called the startAudio function with speakerOnly option and after that when I am trying to start the mic by stopping the audio and starting the audio without speakerOnly option then sometimes error is coming and sometimes it doesn’t.

Also, I am using Chrome for now.

Hey @vk-jangid

Thanks for the detailed explanation.

I will give you more information about the startAudio method. If the speakerOnly option is set, the Video SDK will not request the microphone permission, otherwise, the microphone permission is required.

Thanks
Vic

The case where I am expecting the error is only where the speakerOnly is set to false.
As I said earlier, At the beginning of the session I am calling startAudio with speakerOnly set to true. At this time I am not expecting any error in any case.
After some time in the session, when I am trying to turn on the mic, As per your suggestion I am stopping the audio first (by calling stopAudio function), and then calling startAudio with speakerOnly set to false.
Only in this case, I am expecting the error but it is not coming, the startAudio function is running successfully.

Hey @vk-jangid

Let me try to use pseudo code to describe your actions:

async function audioHandler(){
  /* The microphone permission was blocked*/
  await stream.startAudio({speakerOnly:true});
  /* After some other things, rejoin the audio with the microphone connected*/
 await stream.stopAudio();
  await stream.startAudio(); // Can hear the sound, but cannot speak? And no error on the console?
}

Is that right?

Thanks
Vic

Yes, this is the case.

Hey @vk-jangid

Thanks for your feedback.

We found this issue, it will be fixed in the next release.

For the current version(1.4.0), if the microphone permission was blocked before the second start audio (without speakerOnly option), a refreshing page action is required.

Thanks
Vic

1 Like

Ok, and one more thing which I am confused about is that when I am starting the audio with speakerOnly option the participant’s data object is as follows -

audio: "computer"
avatar: ""
bVideoOn: false
displayName: "Mrudula"
isHost: false
isManager: true
muted: false
sharerOn: undefined
sharerPause: undefined
userId: 67111936

so in this case how to show on the UI that the microphone is off or on?
I was using the muted key to decide the mic on and off state but in the speakerOnly state the muted value is false, and I can’t use this.

Hey @vk-jangid

The participant item doesn’t provide detailed audio information, so you’d better maintain the state of the microphone connected locally, via speakerOnly or the rejected promise USER_FORBIDDEN_MICROPHONE.
Hope this can help you.

Thanks
Vic

Ok, but how to decide on the other participant’s screen?

Hey @vk-jangid

The Video SDK Web has a feature named Command Channel, the microphone state can be broadcasted via this channel.

Thanks
Vic

Ok, is there any plan in the future to add detailed audio information?

Hey @vk-jangid

We have no plan to add the microphone status in audio yet.

Thanks
Vic