From 2d1c5204c176566fa0097cdc19f9bb936c05246b Mon Sep 17 00:00:00 2001 From: Leonid Liansky Date: Wed, 20 May 2020 18:24:20 -0400 Subject: [PATCH] Fixing multiple video renderers on the same HTML page for Flutter Web --- lib/web/rtc_video_view.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/web/rtc_video_view.dart b/lib/web/rtc_video_view.dart index 744cd85ff1..5cf0740daf 100644 --- a/lib/web/rtc_video_view.dart +++ b/lib/web/rtc_video_view.dart @@ -83,6 +83,7 @@ class RTCVideoRenderer { x.autoplay = true; x.muted = false; x.srcObject = stream.jsStream; + x.id = stream.id; _htmlVideoElement = x; _videoViews.add(x); return x; @@ -139,7 +140,11 @@ class RTCVideoRenderer { if (_htmlVideoElement != null) return _htmlVideoElement; final fltPv = HTML.document.getElementsByTagName('flt-platform-view'); if (fltPv.isEmpty) return null; - return (fltPv.first as HTML.Element).shadowRoot.lastChild; + final lastChild = (fltPv.first as HTML.Element).shadowRoot.lastChild; + if (!(lastChild is HTML.VideoElement)) return null; + final videoElement = lastChild as HTML.VideoElement; + if (_srcObject != null && videoElement.id != _srcObject.id) return null; + return lastChild; } Future dispose() async {