8000 Merge pull request #260 from leonidl/flutter_web_multirenderer · hicodeboy/flutter-webrtc@9353964 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9353964

Browse files
authored
Merge pull request flutter-webrtc#260 from leonidl/flutter_web_multirenderer
Fixing multiple video renderers on the same HTML page for Flutter Web
2 parents 3183206 + 2d1c520 commit 9353964

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/web/rtc_video_view.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class RTCVideoRenderer {
8383
x.autoplay = true;
8484
x.muted = false;
8585
x.srcObject = stream.jsStream;
86+
x.id = stream.id;
8687
_htmlVideoElement = x;
8788
_videoViews.add(x);
8889
return x;
@@ -139,7 +140,11 @@ class RTCVideoRenderer {
139140
if (_htmlVideoElement != null) return _htmlVideoElement;
140141
final fltPv = HTML.document.getElementsByTagName('flt-platform-view');
141142
if (fltPv.isEmpty) return null;
142-
return (fltPv.first as HTML.Element).shadowRoot.lastChild;
143+
final lastChild = (fltPv.first as HTML.Element).shadowRoot.lastChild;
144+
if (!(lastChild is HTML.VideoElement)) return null;
145+
final videoElement = lastChild as HTML.VideoElement;
146+
if (_srcObject != null && videoElement.id != _srcObject.id) return null;
147+
return lastChild;
143148
}
144149

145150
Future<Null> dispose() async {

0 commit comments

Comments
 (0)
0