twilio / twilio-video.js

Twilio’s Programmable Video JavaScript SDK
https://www.twilio.com/docs/video/javascript
Other
571 stars 217 forks source link

ScreenShare OnEnded is not fired when the stop button is used in Chrome #849

Closed andreaswissel closed 4 years ago

andreaswissel commented 4 years ago

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:

participant.on('trackSubscribed', track) => {
       if (track.kind === 'video') {
        stream.addEventListener('ended', () => {
          debugger;
       })
}

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:

manjeshbhargav commented 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:

Thanks,

Manjesh Malavalli JSDK Team

andreaswissel commented 4 years ago

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!

manjeshbhargav commented 4 years ago

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