Open felipeYoungi opened 1 year ago
Okay so after a few days of investigation I couldn't find anything to solve this issue here are the approaches I took and how they didn't turned out to work: Approach number 1: First thing I tried is(of course) to try to unsubscribe to the videoTrack of the users that weren't being shown. Let's say my screen could fit 5 cameras of the 10 participants that were actually on the call, so I tried to unsubscribe from the videoTrack but keep suscribed to the audioTrack(bc I still want to hear them). Turns out I couldn't find a way to unscubscribe to a single track. The only way I found to subscribe/unsubscribe a track is through unsubscribing the participant(https://spaces-js-docs.mux.dev/classes/RemoteParticipant.html#unsubscribe).The problem with this method is that it unsubscribes the participant from BOTH tracks: audio and video so this approach is no longer valid since I still want to . Approach number 2: So after accepting the fact that there's no way to unsubscribe myself from the track I said: okay, why don't we just unsubscribe from both tracks and when the participant starts speaking we subscribe to his tracks back again? I implemented this and I ran some tests. The result was it FAILED, when the remote participant started speaking I couldn't hear him for like 1-2 seconds and then I could start hearing him so this ain't the right solution.
@marcovidonis aiutooooo
Hi Felipe,
yes, you want to remain subscribed to the participant, otherwise re-subscribing will introduce a delay, as you experienced!
I think a possible solution would be to stop the video track. Our Mux spaces wrapper exposes the MediaStreamTrack
object, so you could just add a stop()
method to the Track
class:
You could also try detaching the track before or after stopping it, but I'm not sure if it's needed...
Then, when you want to show the video again, you could call Participant.getTracks()
, select the video track and add it to a <video>
element.
Hope this helps, let me know how it goes!
Hey Marco, thank you so much for you answer! I'll give it a shot an I'll let you know
We should unsubscribe to the participants that aren't being shown on screen, also we should re-subscribe once the scren size is big enough to fit the camera or the participants speaks gains priority.