onUserVideoStateChanged method

void onUserVideoStateChanged(
  1. String userId,
  2. TUIVideoStreamType streamType,
  3. bool hasVideo,
  4. TUIChangeReason reason,
)

Implementation

void onUserVideoStateChanged(String userId, TUIVideoStreamType streamType, bool hasVideo, TUIChangeReason reason) {
  if (streamType == TUIVideoStreamType.screenStream) {
    if (hasVideo) {
      userState.hasScreenStreamUserList.value.add(userId);
    } else {
      userState.hasScreenStreamUserList.value.remove(userId);
    }
    final LinkedHashSet<String> tempList = LinkedHashSet<String>();
    tempList.addAll(userState.hasScreenStreamUserList.value);
    userState.hasScreenStreamUserList.value = tempList;
    return;
  }
  if (hasVideo) {
    userState.hasVideoStreamUserList.value.add(userId);
  } else {
    userState.hasVideoStreamUserList.value.remove(userId);
  }
  final LinkedHashSet<String> tempList = LinkedHashSet<String>();
  tempList.addAll(userState.hasVideoStreamUserList.value);
  userState.hasVideoStreamUserList.value = tempList;
  if (userId == userState.selfInfo.userId) {
    mediaState.isCameraOpened.value = hasVideo;
  }
}