Flutter webrtc screen sharing

1,027

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());
    }
  }
}
Share:
1,027
Dima Nizanov
Author by

Dima Nizanov

Updated on January 01, 2023

Comments

  • Dima Nizanov
    Dima Nizanov over 1 year

    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?

    • Admin
      Admin over 2 years
      Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    • Hardik1344
      Hardik1344 about 2 years
      @YeasinSheikh can you please share the demo url for screen share?
    • Yeasin Sheikh
      Yeasin Sheikh about 2 years
      WebRTC repo and callPage @Hardik1344
    • Hardik1344
      Hardik1344 about 2 years
      thank you sir, I want to add screen share functionality. is it available in your repo sir?
  • Hardik1344
    Hardik1344 about 2 years
    can you please share full demo example if you have?
  • Dyadee
    Dyadee about 2 years
    @Mojtaba Ghiasi were you able to run this on iOS and Android? For me it only functions well for desktop browsers.