addTrack method

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

Adds the given MediaStreamTrack to this MediaStream.

Implementation

@override
Future<void> addTrack(MediaStreamTrack track,
    {bool addToNative = true}) async {
  if (track.kind == 'audio') {
    _audioTracks.add(track);
  } else {
    _videoTracks.add(track);
  }

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