onAudioSubscribeStateChanged method

FutureOr<void> onAudioSubscribeStateChanged(
  1. dynamic streamId,
  2. dynamic streamInfo,
  3. dynamic state,
  4. dynamic reason,
)
override

@detail callback @valid since 3.60. Since version 3.60, this callback replaces onStreamStateChanged and onStreamSubscribed for reporting the state changes of the subscription to audio streams. If you have upgraded to SDK version 3.60 or later and are still using this two methods, please migrate to this callback. @author shenpengliang @brief Callback on state changes of the subscription to microphone-audio streams. @param streamId The ID of the stream, used to identify a specific audio stream. @param streamInfo The stream information structure, containing detailed information such as room ID and user ID. See StreamInfo{@link #StreamInfo}. @param state Room state code. See SubscribeState{@link #SubscribeState} for more. @param reason The reason why room state changes. See SubscribeStateChangeReason{@link #SubscribeStateChangeReason} for more. @note You will receive this callback after calling subscribeStreamAudio{@link #RTCRoom#subscribeStreamAudio}.

Implementation

FutureOr<void> onAudioSubscribeStateChanged(dynamic streamId,
    dynamic streamInfo, dynamic state, dynamic reason) async {
  if ($instance == null || $instance is! IRTCRoomEventHandler) {
    return;
  }
  return ($instance as IRTCRoomEventHandler)
      .onAudioSubscribeStateChanged
      ?.call(
          streamId.toString(),
          t_SubscribeState.android_to_code($p_a.SubscribeState.values
              .firstWhere((t) => t.$value == state || t.name == state)),
          t_SubscribeStateChangeReason.android_to_code($p_a
              .SubscribeStateChangeReason.values
              .firstWhere((t) => t.$value == reason || t.name == reason)));
}