logo
On this page

ZegoAudioEffectPlayer

ZegoAudioEffectPlayer

Declared in ZegoExpressDefines.h

Methods

setEventHandler:

setEventHandler:
- (void)setEventHandler:(nullable id<ZegoAudioEffectPlayerEventHandler>) handler;
Set audio effect player event handler.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
handlernullable 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:

start:path:config:
- (void)start:(unsigned int) audioEffectID path:(nullable NSString *) path config:(ZegoAudioEffectPlayConfig *) config;
Start playing audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intDescription: 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.
pathnullable 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].
configZegoAudioEffectPlayConfig *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:

stop:
- (void)stop:(unsigned int) audioEffectID;
Stop playing audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intID 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:

pause:
- (void)pause:(unsigned int) audioEffectID;
Pause playing audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intID 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:

resume:
- (void)resume:(unsigned int) audioEffectID;
Resume playing audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intID 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

stopAll
- (void)stopAll;
Stop playing all audio effect.
Declared in ZegoExpressDefines.h

Stop playing all audio effect.

  • When to call: Some audio effects are Playing.
  • Available since: 1.16.0
  • Restrictions: None.

pauseAll

pauseAll
- (void)pauseAll;
Pause playing all audio effect.
Declared in ZegoExpressDefines.h

Pause playing all audio effect.

  • When to call: It can be called after [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: None.

resumeAll

resumeAll
- (void)resumeAll;
Resume playing all audio effect.
Declared in ZegoExpressDefines.h

Resume playing all audio effect.

  • When to call: It can be called after [pauseAll].
  • Available since: 1.16.0
  • Restrictions: None.

seekTo:audioEffectID:callback:

seekTo:audioEffectID:callback:
- (void)seekTo:(unsigned long long) millisecond audioEffectID:(unsigned int) audioEffectID callback:(nullable ZegoAudioEffectPlayerSeekToCallback) callback;
Set the specified playback progress.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
millisecondunsigned long longPoint in time of specified playback progress.
audioEffectIDunsigned intID for the audio effect.
callbacknullable ZegoAudioEffectPlayerSeekToCallbackThe 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:

setVolume:audioEffectID:
- (void)setVolume:(int) volume audioEffectID:(unsigned int) audioEffectID;
Set volume for a single audio effect. Both the local play volume and the publish volume are set.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
volumeintVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.
audioEffectIDunsigned intID 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:

setPlayVolume:audioEffectID:
- (void)setPlayVolume:(int) volume audioEffectID:(unsigned int) audioEffectID;
Set local play volume for a single audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
volumeintVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.
audioEffectIDunsigned intID 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:

setPublishVolume:audioEffectID:
- (void)setPublishVolume:(int) volume audioEffectID:(unsigned int) audioEffectID;
Set publish volume for a single audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
volumeintVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.
audioEffectIDunsigned intID 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:

setVolumeAll:
- (void)setVolumeAll:(int) volume;
Set volume for all audio effect. Both the local play volume and the publish volume are set.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
volumeintVolume. <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:

setPlayVolumeAll:
- (void)setPlayVolumeAll:(int) volume;
Set local play volume for all audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
volumeintVolume. <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:

setPublishVolumeAll:
- (void)setPublishVolumeAll:(int) volume;
Set publish volume for all audio effect.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
volumeintVolume. <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:

setPlaySpeed:audioEffectID:
- (void)setPlaySpeed:(float) speed audioEffectID:(unsigned int) audioEffectID;
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).
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
speedfloatThe speed of play. <br>Value range: The range is 0.5 ~ 2.0. <br>Default value: The default is 1.0.
audioEffectIDunsigned intID 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:

getTotalDuration:
- (unsigned long long)getTotalDuration:(unsigned int) audioEffectID;
Get the total duration of the specified audio effect resource.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intID 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:

getCurrentProgress:
- (unsigned long long)getCurrentProgress:(unsigned int) audioEffectID;
Get current playback progress.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intID 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:

loadResource:audioEffectID:callback:
- (void)loadResource:(NSString *) path audioEffectID:(unsigned int) audioEffectID callback:(nullable ZegoAudioEffectPlayerLoadResourceCallback) callback;
Load audio effect resource.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
pathNSString *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.
audioEffectIDunsigned intID for the audio effect.
callbacknullable ZegoAudioEffectPlayerLoadResourceCallbackload 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:

unloadResource:
- (void)unloadResource:(unsigned int) audioEffectID;
Unload audio effect resource.
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intID 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:

updatePosition:position:
- (void)updatePosition:(unsigned int) audioEffectID position:(const float[_Nonnull 3]) position;
Update the position of the audio effect player (audio source).
Declared in ZegoExpressDefines.h

Parameters

NameTypeDescription
audioEffectIDunsigned intID for the audio effect.
positionconst 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

getIndex
- (NSNumber *)getIndex;
Get audio effect player index.
Declared in ZegoExpressDefines.h

Get audio effect player index.

  • When to call: It can be called after [createAudioEffectPlayer].
  • Available since: 1.16.0
  • Restrictions: None.

Audio effect player index.

Previous

zegoaudioeffectplayconfig

Next

zegoaudioframeparam

On this page

Back to top