updateTrack method

  1. @internal
Future<bool> updateTrack(
  1. T? newValue
)

Implementation

@internal
Future<bool> updateTrack(T? newValue) async {
  if (_track == newValue) return false;
  // dispose previous track (if exists)
  await _track?.dispose();
  _track = newValue;

  if (newValue != null) {
    // listen for Track's muted events
    final listener = newValue.createListener()
      ..on<InternalTrackMuteUpdatedEvent>(
          (event) => _onTrackMuteUpdatedEvent(event));
    // dispose listener when the track is disposed
    newValue.onDispose(() => listener.dispose());
  }

  return true;
}