removePublishedTrack method

Future<void> removePublishedTrack(
  1. String trackSid,
  2. {bool notify = true}
)

Implementation

Future<void> removePublishedTrack(String trackSid,
    {bool notify = true}) async {
  logger.finer('removePublishedTrack track sid: $trackSid, notify: $notify');
  final pub = trackPublications.remove(trackSid);
  if (pub == null) {
    logger.warning('Publication not found $trackSid');
    return;
  }
  await pub.dispose();

  final track = pub.track;
  // if has track
  if (track != null) {
    await track.stop();
    [events, room.events].emit(TrackUnsubscribedEvent(
      participant: this,
      track: track,
      publication: pub,
    ));
  }

  if (notify) {
    [events, room.events].emit(TrackUnpublishedEvent(
      participant: this,
      publication: pub,
    ));
  }

  await pub.dispose();
}