Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

javascript - Twilio - remove track after participant stops sharing screen

So, once the participant stops sharing using the "stop sharing" button on chrome, it should remove the video-tag (or at least make it black) from the other subscribers screen with the following code:

   $('#shareScreen').click(async function(){
      const stream = await navigator.mediaDevices.getDisplayMedia();
      let screenTrack = new Twilio.Video.LocalVideoTrack(stream.getTracks()[0]);
      room.localParticipant.publishTrack(screenTrack);
      screenTrack.once('stopped', () => {
        room.localParticipant.unpublishTrack(screenTrack);
        screenTrack.stop();
        screenTrack = null;
      });
    });

But I still see a still screen. The window is still being displayed and the video tag has not been removed from the other participants screen

The window is still being displayed and the video tag has not been removed from the other participants screen

How do I fix this and remove the screen sharing video after the participant has stopped sharing his/her screen?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...