Implementation
@override
set srcObject(MediaStream? stream) {
if (_disposed) {
throw 'Can\'t set srcObject: The RTCVideoPlatformController is disposed';
}
if (_viewId == null) throw 'Call initialize before setting the stream';
if (_srcObject == stream) return;
_srcObject = stream;
onSrcObjectChange?.call();
WebRTC.invokeMethod(
'videoPlatformViewRendererSetSrcObject',
<String, dynamic>{
'viewId': _viewId,
'streamId': stream?.id ?? '',
'ownerTag': stream?.ownerTag ?? '',
},
)
.then((_) {
value = (stream == null)
? RTCVideoValue.empty
: value.copyWith(renderVideo: renderVideo);
})
.catchError((e) {
print(
'Got exception for RTCVideoPlatformController::setSrcObject: ${e.message}',
);
}, test: (e) => e is PlatformException);
}