ZegoAudioEffectPlayer
ZegoAudioEffectPlayer
Declared in ZegoExpressDefines.h
Methods
setEventHandler:
- (void)setEventHandler:(nullable id<ZegoAudioEffectPlayerEventHandler>) handler;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| handler | nullable id<ZegoAudioEffectPlayerEventHandler> | event handler for audio effect player. |
Details
Set audio effect player event handler.
- When to call: It can be called after [createAudioEffectPlayer].
- Related APIs: [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: None.
start:path:config:
- (void)start:(unsigned int) audioEffectID path:(nullable NSString *) path config:(ZegoAudioEffectPlayConfig *) config;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | Description: ID for the audio effect. The SDK uses audioEffectID to control the playback of sound effects. The SDK does not force the user to pass in this parameter as a fixed value. It is best to ensure that each sound effect can have a unique ID. The recommended methods are static self-incrementing ID or the hash of the incoming sound effect file path. |
| path | nullable NSString * | The absolute path of the local resource. <br>Value range: "assets://"、"ipod-library://" and network url are not supported. Set path as nil or "" if resource is loaded already using [loadResource]. |
| config | ZegoAudioEffectPlayConfig * | Audio effect playback configuration. <br>Default value: Set NULL will only be played once, and will not be mixed into the publishing stream. |
Details
Start playing audio effect. The default is only played once and is not mixed into the publishing stream, if you want to change this please modify [config] param.
- Use cases: When you need to play short sound effects, such as applause, cheers, etc., you can use this interface to achieve, and further configure the number of plays through the [config] parameter, and mix the sound effects into the push stream.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: None.
stop:
- (void)stop:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Stop playing the specified audio effect [audioEffectID].
- When to call: The specified [audioEffectID] is [start].
- Available since: 1.16.0
- Restrictions: None.
pause:
- (void)pause:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Pause playing the specified audio effect [audioEffectID].
- When to call: The specified [audioEffectID] is [start].
- Available since: 1.16.0
- Restrictions: None.
resume:
- (void)resume:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Resume playing the specified audio effect [audioEffectID].
- When to call: The specified [audioEffectID] is [pause].
- Available since: 1.16.0
- Restrictions: None.
stopAll
- (void)stopAll;ZegoExpressDefines.hStop playing all audio effect.
- When to call: Some audio effects are Playing.
- Available since: 1.16.0
- Restrictions: None.
pauseAll
- (void)pauseAll;ZegoExpressDefines.hPause playing all audio effect.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: None.
resumeAll
- (void)resumeAll;ZegoExpressDefines.hResume playing all audio effect.
- When to call: It can be called after [pauseAll].
- Available since: 1.16.0
- Restrictions: None.
seekTo:audioEffectID:callback:
- (void)seekTo:(unsigned long long) millisecond audioEffectID:(unsigned int) audioEffectID callback:(nullable ZegoAudioEffectPlayerSeekToCallback) callback;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| millisecond | unsigned long long | Point in time of specified playback progress. |
| audioEffectID | unsigned int | ID for the audio effect. |
| callback | nullable ZegoAudioEffectPlayerSeekToCallback | The result of seek. |
Details
Set the specified audio effect playback progress. Unit is millisecond.
- When to call: The specified [audioEffectID] is[start], and not finished.
- Available since: 1.16.0
- Restrictions: None.
setVolume:audioEffectID:
- (void)setVolume:(int) volume audioEffectID:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| volume | int | Volume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100. |
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Set volume for a single audio effect. Both the local play volume and the publish volume are set.
- When to call: The specified [audioEffectID] is [start].
- Available since: 1.16.0
- Restrictions: None.
setPlayVolume:audioEffectID:
- (void)setPlayVolume:(int) volume audioEffectID:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| volume | int | Volume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100. |
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Set local play volume for a single audio effect.
- When to call: The specified [audioEffectID] is [start].
- Available since: 3.11.0
- Restrictions: None.
setPublishVolume:audioEffectID:
- (void)setPublishVolume:(int) volume audioEffectID:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| volume | int | Volume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100. |
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Set publish volume for a single audio effect.
- When to call: The specified [audioEffectID] is [start].
- Available since: 3.11.0
- Restrictions: None.
setVolumeAll:
- (void)setVolumeAll:(int) volume;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| volume | int | Volume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100. |
Details
Set volume for all audio effect. Both the local play volume and the publish volume are set.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: None.
setPlayVolumeAll:
- (void)setPlayVolumeAll:(int) volume;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| volume | int | Volume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100. |
Details
Set local play volume for all audio effect.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 3.11.0
- Restrictions: None.
setPublishVolumeAll:
- (void)setPublishVolumeAll:(int) volume;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| volume | int | Volume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100. |
Details
Set publish volume for all audio effect.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 3.11.0
- Restrictions: None.
setPlaySpeed:audioEffectID:
- (void)setPlaySpeed:(float) speed audioEffectID:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| speed | float | The speed of play. <br>Value range: The range is 0.5 ~ 2.0. <br>Default value: The default is 1.0. |
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Set the playback speed for a given audio effect. Both the local play speed and the publish speed are set. (separate settings are not supported).
- When to call: The specified [audioEffectID] is [start].
- Available since: 2.18.0
- Restrictions: None.
getTotalDuration:
- (unsigned long long)getTotalDuration:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Get the total duration of the specified audio effect resource. Unit is millisecond.
- When to call: You should invoke this function after the audio effect resource already loaded, otherwise the return value is 0.
- Related APIs: [start], [loadResource].
- Available since: 1.16.0
- Restrictions: It can be called after [createAudioEffectPlayer].
Return
Unit is millisecond.
getCurrentProgress:
- (unsigned long long)getCurrentProgress:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | ID for the audio effect. |
Details
Get current playback progress of the specified audio effect. Unit is millisecond.
- When to call: You should invoke this function after the audio effect resource already loaded, otherwise the return value is 0.
- Related APIs: [start], [loadResource].
- Available since: 1.16.0
- Restrictions: None.
loadResource:audioEffectID:callback:
- (void)loadResource:(NSString *) path audioEffectID:(unsigned int) audioEffectID callback:(nullable ZegoAudioEffectPlayerLoadResourceCallback) callback;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| path | NSString * | the absolute path of the audio effect resource and cannot be nil or "". <br>Value range: "assets://"、"ipod-library://" and network url are not supported. |
| audioEffectID | unsigned int | ID for the audio effect. |
| callback | nullable ZegoAudioEffectPlayerLoadResourceCallback | load audio effect resource result. |
Details
Load audio effect resource.
- Use cases: In a scene where the same sound effect is played frequently, the SDK provides the function of preloading the sound effect file into the memory in order to optimize the performance of repeatedly reading and decoding the file.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: Preloading supports loading up to 15 sound effect files at the same time, and the duration of the sound effect files cannot exceed 30s, otherwise an error will be reported when loading.
unloadResource:
- (void)unloadResource:(unsigned int) audioEffectID;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | ID for the audio effect loaded. |
Details
Unload the specified audio effect resource.
- When to call: After the sound effects are used up, related resources can be released through this function; otherwise, the SDK will release the loaded resources when the AudioEffectPlayer instance is destroyed.
- Related APIs: [loadResource].
- Available since: 1.16.0
- Restrictions: None.
updatePosition:position:
- (void)updatePosition:(unsigned int) audioEffectID position:(const float[_Nonnull 3]) position;ZegoExpressDefines.hParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | unsigned int | ID for the audio effect. |
| position | const float[_Nonnull 3] | The unit vector of the front axis of its own coordinate system. The parameter is a float array with a length of 3. |
Details
Update the position of the audio effect player (audio source).
- Use cases: The audio effect player also needs to have 3D spatial sound.
- When to call: Listen to the [onAudioEffectPlayStateUpdate] callback, please call this interface after the player state is ZegoAudioEffectPlayState.Playing and before ZegoAudioEffectPlayState.NoPlay/PlayEnded.
- Available since: 3.6.0
- Restrictions: This interface needs to be used in conjunction with the RangeAudio/RangeScene module. This interface can only be called successfully after the RangeAudio/RangeScene module enables 3D sound effects.
getIndex
- (NSNumber *)getIndex;ZegoExpressDefines.hGet audio effect player index.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: None.
Audio effect player index.
