removeMediaTrack method
Implementation
@override
Future<MediaStream> removeMediaTrack(String trackId) {
if (localStream == null) {
return Future.error(IllegalStateException(
'Can\'t remove the track cause the local media stream doesn\'t exist'));
}
var track = localStream?.getTrackById(trackId);
if (track == null) {
return Future.error(IllegalStateException(
'Can\'t remove the track cause it not found in the local media stream'));
}
return Future.wait(channels
.map((userId, peerConnection) => MapEntry(
userId,
peerConnection.removeTrack(trackId),
))
.values)
.then((_) {
localStream?.removeTrack(track);
track.stop();
onLocalStreamReceived?.call(localStream!);
return localStream!;
});
}