我正在尝试在我的代码中使用window.navigator.getUserMedia,并且这向我显示了奇怪的长错误。
这是我的代码:
window.navigator.getUserMedia(audio: true, video: true).then((stream) {
_localRenderer.srcObject = stream;
});
错误:
A value of type 'MediaStream (where MediaStream is defined in /home/klaus/developement/flutter/bin/cache/pkg/sky_engine/lib/html/html_dart2js.dart)' can't be assigned to a variable of type 'MediaStream (where MediaStream is defined in /home/klaus/developement/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.3.2/lib/src/media_stream.dart)'.
Try changing the type of the variable, or casting the right-hand type to 'MediaStream (where MediaStream is defined in /home/klaus/developement/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webrtc-0.3.2/lib/src/media_stream.dart)'
答案 0 :(得分:0)
使用MediaDevices代替导航器 像这样
MediaDevices.getUserMedia(constrains).then((MediaStream stream) {
_localRenderer.srcObject = stream;
}