getDisplayMedia method
Calling this method will prompts the user to select and grant permission to capture the contents of a display or portion thereof (such as a window) as a MediaStream. The resulting stream can then be recorded using the MediaStream Recording API or transmitted as part of a WebRTC session.
Implementation
@override
Future<MediaStream> getDisplayMedia(
Map<String, dynamic> mediaConstraints) async {
try {
final response = await WebRTC.invokeMethod(
'getDisplayMedia',
<String, dynamic>{'constraints': mediaConstraints},
);
if (response == null) {
throw Exception('getDisplayMedia return null, something wrong');
}
String streamId = response['streamId'];
var stream = MediaStreamNative(streamId, 'local');
stream.setMediaTracks(response['audioTracks'], response['videoTracks']);
return stream;
} on PlatformException catch (e) {
throw 'Unable to getDisplayMedia: ${e.message}';
}
}