stop method

Future<void> stop()

Releases the track and the device behind it.

Implementation

Future<void> stop() async {
  if (_isEnded) return;
  try {
    // The track lives natively, so releasing it is a channel call rather
    // than stopping libwebrtc tracks in the Dart heap.
    await _channel.invokeMethod('track.dispose', {'trackId': mediaStream.id});
  } catch (error) {
    log("ERROR: Unable to stop track :: $error");
  }
  // Ended even when dispose failed: the handle is unusable either way, and
  // leaving `isEnded` false would let a caller join with a dead track.
  _markEnded(null);
}