subscribeStreamAudio method

Future<int?> subscribeStreamAudio({
  1. required string streamId,
  2. required bool subscribe,
})

@detail api @valid since 3.60. Since version 3.60, this interface replaces the subscribeStream, unsubscribeStream, subscribeScreen and unsubscribeScreen methods for the below functions. If you have upgraded to version 3.60 or later and are still using these methods, please migrate to this interface. @region Room Management @author xuyiling.x10 @brief Subscribes to or unsubscribes from the specific remote audio streams captured by the microphone. @param streamId The ID of the target remote audio stream. @param subscribe Whether to subscribe to the audio stream.
- true: Subscribe. - false: Unsubscribe. @return - 0: Success. - < 0 : Fail. See ReturnStatus{@link #ReturnStatus} for more details. @note - If you have already subscribed to the remote audio stream (manually or automatically) when you call this method, the subscription configuration will be updated based on the parameters passed in this call. - You must call onUserPublishStreamAudio{@link #IRTCRoomEventHandler#onUserPublishStreamAudio} callback to get the current remote microphone stream information in the room, and then call this method to subscribe to the remote media streams. - After you call this method, you will receive onAudioSubscribeStateChanged{@link #IRTCRoomEventHandler#onAudioSubscribeStateChanged} notification method call results. - After you successfully subscribe to the remote audio stream, the subscription relationship will continue until you call subscribeStreamAudio{@link #RTCRoom#subscribeStreamAudio} to unsubscribe from it or the local user leaves the room. - Any other exceptions will be included in onAudioSubscribeStateChanged{@link #IRTCRoomEventHandler#onAudioSubscribeStateChanged} callback notification.

Implementation

Future<int?> subscribeStreamAudio(
    {required string streamId, required bool subscribe}) async {
  $a() =>
      ($instance as $p_a.RTCRoom).subscribeStreamAudio(streamId, subscribe);
  $i() => ($instance as $p_i.ByteRTCRoom)
      .subscribeStreamAudio(streamId, subscribe);

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