logo
On this page

ZegoAudioEffectPlayer

ZegoAudioEffectPlayer

Declared in ZegoAudioEffectPlayer.java

Methods

setEventHandler

setEventHandler
public void setEventHandler(IZegoAudioEffectPlayerEventHandler handler)
Set audio effect player event handler.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
handlerIZegoAudioEffectPlayerEventHandlerevent 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

start
public void start(int audioEffectID, String path, ZegoAudioEffectPlayConfig config)
Start playing audio effect.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintDescription: 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.
pathStringThe absolute path of the local resource. <br>Value range: "assets://"、"ipod-library://" and network url are not supported. Set path as null or "" if resource is loaded already using [loadResource].
configZegoAudioEffectPlayConfigAudio 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
public void stop(int audioEffectID)
Stop playing audio effect.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID 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
public void pause(int audioEffectID)
Pause playing audio effect.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID 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
public void resume(int audioEffectID)
Resume playing audio effect.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID 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
public void stopAll()
Stop playing all audio effect.
Declared in ZegoAudioEffectPlayer.java

Stop playing all audio effect.

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

pauseAll

pauseAll
public void pauseAll()
Pause playing all audio effect.
Declared in ZegoAudioEffectPlayer.java

Pause playing all audio effect.

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

resumeAll

resumeAll
public void resumeAll()
Resume playing all audio effect.
Declared in ZegoAudioEffectPlayer.java

Resume playing all audio effect.

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

seekTo

seekTo
public void seekTo(int audioEffectID, long millisecond, IZegoAudioEffectPlayerSeekToCallback callback)
Set the specified playback progress.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID for the audio effect.
millisecondlongPoint in time of specified playback progress.
callbackIZegoAudioEffectPlayerSeekToCallbackThe 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

setVolume
public void setVolume(int audioEffectID, int volume)
Set volume for a single audio effect. Both the local play volume and the publish volume are set.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID for the audio effect.
volumeintVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.

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

setPlayVolume
public void setPlayVolume(int audioEffectID, int volume)
Set local play volume for a single audio effect.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID for the audio effect.
volumeintVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.

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

setPublishVolume
public void setPublishVolume(int audioEffectID, int volume)
Set publish volume for a single audio effect.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID for the audio effect.
volumeintVolume. <br>Value range: The range is 0 ~ 200. <br>Default value: The default is 100.

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
public void setVolumeAll(int volume)
Set volume for all audio effect. Both the local play volume and the publish volume are set.
Declared in ZegoAudioEffectPlayer.java

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
public void setPlayVolumeAll(int volume)
Set local play volume for all audio effect.
Declared in ZegoAudioEffectPlayer.java

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
public void setPublishVolumeAll(int volume)
Set publish volume for all audio effect.
Declared in ZegoAudioEffectPlayer.java

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

setPlaySpeed
public void setPlaySpeed(int audioEffectID, float speed)
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 ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID for the audio effect.
speedfloatThe speed of play. <br>Value range: The range is 0.5 ~ 2.0. <br>Default value: The default is 1.0.

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
public long getTotalDuration(int audioEffectID)
Get the total duration of the specified audio effect resource.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID 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
public long getCurrentProgress(int audioEffectID)
Get current playback progress.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID 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

loadResource
public void loadResource(int audioEffectID, String path, IZegoAudioEffectPlayerLoadResourceCallback callback)
Load audio effect resource.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID for the audio effect.
pathStringthe absolute path of the audio effect resource and cannot be nil or "". <br>Value range: "assets://"、"ipod-library://" and network url are not supported.
callbackIZegoAudioEffectPlayerLoadResourceCallbackload audio effect resource result.

Details

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. 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 Android developers can pass parameters through Uri, namely:String path = uri.toString();

unloadResource

unloadResource
public void unloadResource(int audioEffectID)
Unload audio effect resource.
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID 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

updatePosition
public void updatePosition(int audioEffectID, float[] position)
Update the position of the audio effect player (audio source).
Declared in ZegoAudioEffectPlayer.java

Parameters

NameTypeDescription
audioEffectIDintID for the audio effect.
positionfloat[]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
public int getIndex()
Get audio effect player index.
Declared in ZegoAudioEffectPlayer.java

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