From afcad289dcd29c9885f12c8cd61983a3522dfff0 Mon Sep 17 00:00:00 2001 From: CloudWebRTC Date: Wed, 9 Nov 2022 09:51:46 +0800 Subject: [PATCH] docs: Add desktop sharing instructions. --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 4a97008..dfb8bd8 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,35 @@ On Android, you would have to define a foreground service in your AndroidManifes On iOS, a broadcast extension is needed in order to capture screen content from other apps. See [setup guide](https://github.com/flutter-webrtc/flutter-webrtc/wiki/iOS-Screen-Sharing#broadcast-extension-quick-setup) for instructions. + +#### Desktop(Windows/macOS) + +On dekstop you can use `ScreenSelectDialog` to select the window or screen you want to share. + + +```dart +try { + final source = await showDialog( + context: context, + builder: (context) => ScreenSelectDialog(), + ); + if (source == null) { + print('cancelled screenshare'); + return; + } + print('DesktopCapturerSource: ${source.id}'); + var track = await LocalVideoTrack.createScreenShareTrack( + ScreenShareCaptureOptions( + sourceId: source.id, + maxFrameRate: 15.0, + ), + ); + await room.localParticipant.publishVideoTrack(track); + } catch (e) { + print('could not publish screen sharing: $e'); +} +``` + ### Advanced track manipulation The setCameraEnabled/setMicrophoneEnabled helpers are wrappers around the Track API.