Configure sound effects for iOS
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.
Parameter description- (int)startAudioAccompanyWithFile:(NSString *)filePath onlyLocalPlay:(BOOL)onlyLocalPlay replaceMic:(BOOL)replaceMic loopCycles:(NSInteger)loopCycles;Parameter Type Description filePath NSString * The file path. onlyLocalPlay BOOL Specifies whether to play only locally. Valid values: YES | NO. replaceMic BOOL Specifies whether to replace the MIC (microphone). Valid values: YES | NO. loopCycles NSInteger The 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.
Parameter description- (int)setAudioAccompanyVolume:(NSInteger)volume;Parameter Type Description volume NSInteger The 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.
Parameter description- (int)setAudioAccompanyPublishVolume:(NSInteger)volume;Parameter Type Description volume NSInteger The 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.
Parameter description- (int)setAudioAccompanyPlayoutVolume:(NSInteger)volume;Parameter Type Description volume NSInteger The 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.
Parameter description- (int)preloadAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath;Parameter Type Description soundId NSInteger The ID assigned by the user to the sound effect file. filePath NSString * 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.
Parameter description- (int)unloadAudioEffectWithSoundId:(NSInteger)soundId;Parameter Type Description soundId NSInteger The 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.
Parameter description- (int)playAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath cycles:(NSInteger)cycles publish:(BOOL)publish;Parameter Type Description soundId NSInteger The ID assigned by the user to the sound effect file. filePath NSString * The path of the sound effect file. cycles NSInteger The number of cycles. You can set -1 or a positive integer. publish BOOL Specifies 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.
Parameter description- (int)pauseAudioEffectWithSoundId:(NSInteger)soundId;Parameter Type Description soundId NSInteger The 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.
Parameter description- (int)resumeAudioEffectWithSoundId:(NSInteger)soundId;Parameter Type Description soundId NSInteger The 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.
Parameter description- (int)stopAudioEffectWithSoundId:(NSInteger)soundId;Parameter Type Description soundId NSInteger The 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.
Parameter description- (int)setAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;Parameter Type Description soundId NSInteger The ID assigned by the user to the sound effect file. volume NSInteger The 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.
Parameter description- (int)getAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId;Parameter Type Description soundId NSInteger The 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.
Parameter description- (int)setAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;Parameter Type Description soundId NSInteger The ID assigned by the user to the sound effect file. volume NSInteger The 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.
Parameter description- (int)getAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId;Parameter Type Description soundId NSInteger The ID assigned by the user to the sound effect file. Return result
0 indicates success. Other error codes are returned.