livekit / client-sdk-flutter

Flutter Client SDK for LiveKit

Home Page:https://docs.livekit.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Capturing external screen-share cancel event

kNoAPP opened this issue · comments

During screen-share, many browsers (including Chrome) open a secondary dialog box that includes a "Stop sharing" button. When this button is pressed, how do I capture the stop-share event so that I can update the UI accordingly and/or invoke LiveKit's unpublish/dispose operations? My "Stop sharing" button inside the Flutter app that invokes LiveKit's SDK is working great. When I trigger a stop-share from the Flutter app (and LiveKit SDK), it works just fine.

However, stop-sharing triggered from this external Chrome button doesn't unpublish the video/audio track automatically. I am left with a black box local to the sharer and remote-participants see the share-screen freeze. The TrackUnsubscribedEvent and TrackUnpublishedEvent are NOT called for remote participants even when ConnectOptions(autoSubscribe: true). So how do I handle this button?

http___localhost_3000 is sharing your screen and audio  10_7_2023 6_44_13 PM

good find, we may need to emit a ScreenCaptureStopedEvent by listening to screenVideoTrack.ended

Your fix works perfectly in my app, thank you!