Configure sound effects for iOS

更新时间: 2026-01-17 20:20:57

Alibaba Cloud RTC SDK provides methods to allow you to configure accompaniment and sound effects. This topic describes how to call these methods.

Accompaniment

  • startAudioAccompanyWithFile (iOS only): Start playing the accompaniment.

    - (int)startAudioAccompanyWithFile:(NSString *)filePath onlyLocalPlay:(BOOL)onlyLocalPlay replaceMic:(BOOL)replaceMic loopCycles:(NSInteger)loopCycles;
    Parameter description
    ParameterTypeDescription
    filePathNSString *The file path.
    onlyLocalPlayBOOLSpecifies whether to play only locally. Valid values: YES | NO.
    replaceMicBOOLSpecifies whether to replace the MIC (microphone). Valid values: YES | NO.
    loopCyclesNSIntegerThe number of cycles. This parameter can be set to -1 or a positive integer.

    Return result

    0 indicates success. Other error codes are returned.

    Important Supports playback of local resources and network resources.
  • pauseAudioAccompany (available for iOS only): Pause playing the accompaniment.

    - (int)pauseAudioAccompany;

    Return result

    0 indicates success. Other error codes are returned.

  • resumeAudioAccompany (iOS only available): Resume playing accompaniment.

    - (int)resumeAudioAccompany;

    Return result

    0 indicates success. Other error codes are returned.

  • stopAudioAccompany (iOS only): Stop accompaniment.

    - (int)stopAudioAccompany;

    Return result

    0 indicates success. Other error codes are returned.

  • setAudioAccompanyVolume: Set the accompaniment volume.

    - (int)setAudioAccompanyVolume:(NSInteger)volume;
    Parameter description
    ParameterTypeDescription
    volumeNSIntegerThe mixing volume. Valid values: 0 to 100. The default value is 50.

    Return result

    0 indicates success. Other error codes are returned.

    Important The volume setting takes effect only after you call the startAudioAccompanyWithFile.
  • setAudioAccompanyPublishVolume (iOS only): Set the volume of streaming after accompaniment.

    - (int)setAudioAccompanyPublishVolume:(NSInteger)volume;
    Parameter description
    ParameterTypeDescription
    volumeNSIntegerThe mixing volume. Valid values: 0 to 100. The default value is 50.

    Return result

    0 indicates success. Other error codes are returned.

    Important The volume setting takes effect only after you call the startAudioAccompanyWithFile.
  • getAudioAccompanyPublishVolume (available for iOS only): Get the volume of the accompaniment stream.

    - (int)getAudioAccompanyPublishVolume;

    Return result

    0 indicates success. Other error codes are returned.

  • setAudioAccompanyPlayoutVolume (iOS only): Set the local volume of the accompaniment.

    - (int)setAudioAccompanyPlayoutVolume:(NSInteger)volume;
    Parameter description
    ParameterTypeDescription
    volumeNSIntegerThe mixing volume. Valid values: 0 to 100. The default value is 50.

    Return result

    0 indicates success. Other error codes are returned.

    Important The volume setting takes effect only after you call the startAudioAccompanyWithFile.
  • getAudioAccompanyPlayoutVolume (iOS only): Get the local volume of the accompaniment.

    - (int)getAudioAccompanyPlayoutVolume;

    Return result

    0 indicates success. Other error codes are returned.

Sound effects

  • preloadAudioEffectWithSoundId (available for iOS only): Preload sound effects.

    - (int)preloadAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.
    filePathNSString *The path of the sound effect file.

    Return result

    0 indicates success. Other error codes are returned.

  • unloadAudioEffectWithSoundId (available for iOS only): Clears preloaded sound effects.

    - (int)unloadAudioEffectWithSoundId:(NSInteger)soundId;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.

    Return result

    0 indicates success. Other error codes are returned.

  • playAudioEffectWithSoundId (available for iOS only): Start playing sound effects.

    - (int)playAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath cycles:(NSInteger)cycles publish:(BOOL)publish;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.
    filePathNSString *The path of the sound effect file.
    cyclesNSIntegerThe number of cycles. You can set -1 or a positive integer.
    publishBOOLSpecifies whether to publish. Valid values: YES | NO.

    Return result

    0 indicates success. Other error codes are returned.

  • pauseAudioEffectWithSoundId (available for iOS only): Pause playback of sound effects.

    - (int)pauseAudioEffectWithSoundId:(NSInteger)soundId;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.

    Return result

    0 indicates success. Other error codes are returned.

  • resumeAudioEffectWithSoundId (available for iOS only): Resume playing sound effects.

    - (int)resumeAudioEffectWithSoundId:(NSInteger)soundId;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.

    Return result

    0 indicates success. Other error codes are returned.

  • stopAudioEffectWithSoundId (iOS only): Stop playing sound effects.

    - (int)stopAudioEffectWithSoundId:(NSInteger)soundId;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.

    Return result

    0 indicates success. Other error codes are returned.

  • setAudioEffectPublishVolumeWithSoundId (available for iOS only): Set the audio stream volume.

    - (int)setAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.
    volumeNSIntegerThe mixing volume. Valid values: 0 to 100. The default value is 50.

    Return result

    0 indicates success. Other error codes are returned.

  • getAudioEffectPublishVolumeWithSoundId (available for iOS only): Obtain the volume of audio ingest.

    - (int)getAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.

    Return result

    0 to 100 is returned as success. Otherwise, an error code is returned.

  • setAudioEffectPlayoutVolumeWithSoundId (iOS only): Set the local volume of the sound effect.

    - (int)setAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.
    volumeNSIntegerThe mixing volume. Valid values: 0 to 100. The default value is 50.

    Return result

    0 indicates success. Other error codes are returned.

  • getAudioEffectPlayoutVolumeWithSoundId (available for iOS only): Get the local volume of the sound effect.

    - (int)getAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId;
    Parameter description
    ParameterTypeDescription
    soundIdNSIntegerThe ID assigned by the user to the sound effect file.

    Return result

    0 indicates success. Other error codes are returned.

上一篇: Play sound effect files on Android 下一篇: Obtain a list of channel members and member details
阿里云首页 音视频通信 相关技术圈