setUserVisibility method

Future<int?> setUserVisibility(
  1. bool enable
)

@detail api @author shenpengliang @brief Set the visibility of the user in the room. The local user is visible to others by default before calling this API.
An RTC room can accommodate a maximum of 50 visible users, and 30 media streams can be published simultaneously. For more information, see Room Capacity. @param enable Visibility of the user in the room.
- true: The user can publish media streams. The other users in the room get informed of the behaviors of the user, such as joining room, starting video capture, and leaving room. - false: The user cannot publish media streams. The other users in the room do not get informed of the behaviors of the user, such as joining room, starting video capture, or leaving room. @return - 0: Success. - < 0 : Failure. See ReturnStatus{@link #ReturnStatus}. You will receive onUserVisibilityChanged{@link #IRTCRoomEventHandler#onUserVisibilityChanged} after calling this API. (Available since v3.54) - If you call this API before joining room, and the set value is different from the default value, you will receive the callback when you join the room.
- If you call this API after joining room, and the current visibility is different from the previous value, you will receive the callback.
- When reconnecting after losing internet connection, if the visibility changes, you will receive the callback.
@note - You can call this API whether the user is in a room or not. - When you call this API while you are in the room, the other users in the room will be informed via the following callback. • When you switch from false to true, they will receive onUserJoined{@link #IRTCRoomEventHandler#onUserJoined}.
• When you switch from true to false, they will receive onUserLeave{@link #IRTCRoomEventHandler#onUserLeave}.
• The invisible user will receive the warning code, WARNING_CODE_PUBLISH_STREAM_FORBIDEN, when trying to publish media streams.

Implementation

Future<int?> setUserVisibility(bool enable) async {
  $a() => ($instance as $p_a.RTCRoom).setUserVisibility(enable);
  $i() => ($instance as $p_i.ByteRTCRoom).setUserVisibility(enable);

  if (Platform.isAndroid) {
    return $a();
  } else if (Platform.isIOS) {
    return $i();
  } else {
    throw UnsupportedError(
        'Not Support Platform ${Platform.operatingSystem}');
  }
}