3

I have a flutter project (iOS, Android) that uses WebRTC. I need to send video from camera (working correctly) and screen capture by WebRTC. How to share the screen on WebRTC with the flutter_webrtc package?

  • 2
    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Oct 10 '21 at 15:47
  • @YeasinSheikh can you please share the demo url for screen share? – Hardik1344 Jan 27 '22 at 07:25
  • [WebRTC repo](https://github.com/yeasin50/Flutter-Video-Calling-App) and [callPage](https://github.com/yeasin50/Flutter-Video-Calling-App/blob/master/lib/screens/call_page.dart) @Hardik1344 – Md. Yeasin Sheikh Jan 27 '22 at 07:36
  • thank you sir, I want to add screen share functionality. is it available in your repo sir? – Hardik1344 Jan 27 '22 at 10:45

1 Answers1

3

You can use the flutter_webrtc plugin and do like this method ( use getDisplayMedia method in webRTC to get display ) :

class ScreenSharing {
  MediaStream? _localStream;
  final RTCVideoRenderer _localRenderer = RTCVideoRenderer();

  Future<void> _makeScreenSharing() async {
    final mediaConstraints = <String, dynamic>{'audio': true, 'video': true};

    try {
      var stream = await navigator.mediaDevices.getDisplayMedia(mediaConstraints);

      _localStream = stream;
      _localRenderer.srcObject = _localStream;
    } catch (e) {
      print(e.toString());
    }
  }
}
Mojtaba Ghiasi
  • 823
  • 6
  • 16