ZegoAudioEffectPlayer
ZegoAudioEffectPlayer
Declared in ZegoAudioEffectPlayer.java
Methods
setEventHandler
public void setEventHandler(IZegoAudioEffectPlayerEventHandler handler)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| handler | IZegoAudioEffectPlayerEventHandler | 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
public void start(int audioEffectID, String path, ZegoAudioEffectPlayConfig config)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | 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 | String | The 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]. |
| 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
public void stop(int audioEffectID)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | 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
public void pause(int audioEffectID)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | 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
public void resume(int audioEffectID)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | 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
public void stopAll()ZegoAudioEffectPlayer.javaStop playing all audio effect.
- When to call: Some audio effects are Playing.
- Available since: 1.16.0
- Restrictions: None.
pauseAll
public void pauseAll()ZegoAudioEffectPlayer.javaPause playing all audio effect.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: None.
resumeAll
public void resumeAll()ZegoAudioEffectPlayer.javaResume playing all audio effect.
- When to call: It can be called after [pauseAll].
- Available since: 1.16.0
- Restrictions: None.
seekTo
public void seekTo(int audioEffectID, long millisecond, IZegoAudioEffectPlayerSeekToCallback callback)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | int | ID for the audio effect. |
| millisecond | long | Point in time of specified playback progress. |
| callback | IZegoAudioEffectPlayerSeekToCallback | 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
public void setVolume(int audioEffectID, int volume)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | int | ID for the audio effect. |
| volume | int | Volume. <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
public void setPlayVolume(int audioEffectID, int volume)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | int | ID for the audio effect. |
| volume | int | Volume. <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
public void setPublishVolume(int audioEffectID, int volume)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | int | ID for the audio effect. |
| volume | int | Volume. <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
public void setVolumeAll(int volume)ZegoAudioEffectPlayer.javaParameters
| 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
public void setPlayVolumeAll(int volume)ZegoAudioEffectPlayer.javaParameters
| 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
public void setPublishVolumeAll(int volume)ZegoAudioEffectPlayer.javaParameters
| 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
public void setPlaySpeed(int audioEffectID, float speed)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | int | ID for the audio effect. |
| speed | float | The 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
public long getTotalDuration(int audioEffectID)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | 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
public long getCurrentProgress(int audioEffectID)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | 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
public void loadResource(int audioEffectID, String path, IZegoAudioEffectPlayerLoadResourceCallback callback)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | int | ID for the audio effect. |
| path | String | 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. |
| callback | IZegoAudioEffectPlayerLoadResourceCallback | load 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
public void unloadResource(int audioEffectID)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | 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
public void updatePosition(int audioEffectID, float[] position)ZegoAudioEffectPlayer.javaParameters
| Name | Type | Description |
|---|---|---|
| audioEffectID | int | ID for the audio effect. |
| position | float[] | 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
public int getIndex()ZegoAudioEffectPlayer.javaGet audio effect player index.
- When to call: It can be called after [createAudioEffectPlayer].
- Available since: 1.16.0
- Restrictions: None.
Audio effect player index.
