onWTNAudioSubscribeStateChanged method

FutureOr<void> onWTNAudioSubscribeStateChanged(
  1. dynamic streamId,
  2. dynamic stateCode,
  3. dynamic reason
)
override

@detail callback @valid since 3.60. 自 3.60 起,该回调替代了 onPlayPublicStreamResult 方法中的 WTN 音频流订阅状态变化通知功能。如果你已升级至 3.60 及以上版本,并且仍在使用该方法,请迁移到此回调。 @author hanchenchen @brief WTN 音频流订阅状态变化回调
通过 subscribeWTNAudioStream{@link #IWTNStream#subscribeWTNAudioStream} 订阅 WTN 音频流后,可以通过本回调获取订阅结果。 @param streamId WTN 音频流的 ID @param stateCode 音频流状态码,参看 WTNSubscribeState{@link #WTNSubscribeState}。 @param reason 订阅状态发生变化的原因. See WTNSubscribeStateChangeReason{@link #WTNSubscribeStateChangeReason}. @order 2

Implementation

FutureOr<void> onWTNAudioSubscribeStateChanged(
    dynamic streamId, dynamic stateCode, dynamic reason) async {
  if ($instance == null || $instance is! IWTNStreamEventHandler) {
    return;
  }
  return ($instance as IWTNStreamEventHandler)
      .onWTNAudioSubscribeStateChanged
      ?.call(
          streamId.toString(),
          t_WTNSubscribeState.android_to_code($p_a.WTNSubscribeState.values
              .firstWhere(
                  (t) => t.$value == stateCode || t.name == stateCode)),
          t_WTNSubscribeStateChangeReason.android_to_code($p_a
              .WTNSubscribeStateChangeReason.values
              .firstWhere((t) => t.$value == reason || t.name == reason)));
}