Closed andreaswissel closed 4 years ago
Hi @andreaswissel ,
Thanks for writing in with your issue. The scenario that you're trying to build can be easily accomplished as follows:
stopped
event and unpublish it:
let localParticipant; // Alice's LocalParticipant
let screenShareTrack; // Alice's screen share LocalVideoTrack
screenShareTrack.on('stopped', () => {
localParticipant.unpublishTrack(screenShareTrack);
});
When you click on Chrome's native "stop sharing button", a stopped
event is emitted on the screenShareTrack
.
unsubscribed
event on the RemoteTrackPublication associated with the screen share Track:
screenSharePublication.on('unsubscribed', remoteScreenShareTrack => {
remoteScreenShareTrack.detach().forEach(videoElement => {
videoElement.remove();
});
});
Please let me know if this works for you.
Thanks,
Manjesh Malavalli JSDK Team
Hi Manjesh,
I didn't think about it this way, yet. I already do some DOM cleanup for the onended
-event so this does indeed work and integrates quite nicely. Thanks!
However, the onended
callback should probably still be called on remote participants to conform with the official spec, I guess?
Thanks again!
Hi @andreaswissel ,
The new unified plan spec does not emit the onended
event anymore. It emits the onmuted
event instead. But I wouldn't recommend depending on these events. You'll get consistent behavior if you follow what I have suggested.
Thanks,
Manjesh Malavalli JSDK Team
I'm trying to cleanup the RemoteParticipant's track whenever the screen sharing is stopped through the use of the native stop button in Chrome. However none of the events provided work in this case. The event is fired just fine when the participant leaves the room (e.g. by refreshing the browser window), pressing the stop button will result in a still image. I have also tried creating a MediaStream from the track's mediaStreamTrack myself, bypassing the attach method, to no avail. I'm not exactly sure if this is a general issue with Chrome itself?
Code to reproduce the issue:
Expected behavior:
Breakpoint should halt the application, indicating that the event has fired and the stream has stopped.
Actual behavior:
No event is fired.
Software versions: