<@U084APK40NS> How can I detect that screensharing...
# ask-ai
r
@millions-hair-24956 How can I detect that screensharing was stopped by browser ? e.g. When sharing screen with firefox, I want to know when it was stopped, so I can update my UI
g
To detect when screen sharing is stopped by the browser, you can listen for the
TrackUnpublished
event in LiveKit. This event is triggered when a local track is unpublished, which includes when screen sharing is stopped. You can attach an event listener to handle this event and update your UI accordingly. Here's a basic example using the LiveKit JS Client SDK:
Copy code
const room = new Room();

room.on(RoomEvent.LocalTrackUnpublished, (trackPublication) => {
  if (trackPublication.track.source === TrackSource.screenShareVideo) {
    console.log('Screen sharing stopped');
    // Update your UI here
  }
});
Would you like more details on this process? Sources: - RoomEvent Documentation 👍 1 button 👎 0 button 💡 Hint: Mention @millions-hair-24956 in the thread for followups.