Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter webrtc screen sharing

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?

like image 308
Dima Nizanov Avatar asked Oct 12 '25 07:10

Dima Nizanov


1 Answers

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());
    }
  }
}
like image 170
Mojtaba Ghiasi Avatar answered Oct 14 '25 20:10

Mojtaba Ghiasi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!