removeTrack method

  1. @override
Future<void> removeTrack(
  1. MediaStreamTrack track, {
  2. bool removeFromNative = true,
})
override

Removes the given MediaStreamTrack object from this MediaStream.

Implementation

@override
Future<void> removeTrack(MediaStreamTrack track,
    {bool removeFromNative = true}) async {
  if (track.kind == 'audio') {
    _audioTracks.removeWhere((it) => it.id == track.id);
  } else {
    _videoTracks.removeWhere((it) => it.id == track.id);
  }

  if (removeFromNative) {
    await WebRTC.invokeMethod('mediaStreamRemoveTrack',
        <String, dynamic>{'streamId': id, 'trackId': track.id});
  }
}