Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ZegoAudioEffectPlayer

Hierarchy

Index

Methods

Abstract getCurrentProgress

  • getCurrentProgress(audioEffectID: number): Promise<number>
  • Get current playback progress.

    Available since: 1.16.0 Description: 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. Restrictions: None. Related APIs: [start], [loadResource].

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    Returns Promise<number>

Abstract getIndex

  • getIndex(): number
  • Get audio effect player index.

    Available since: 1.16.0 Description: Get audio effect player index. When to call: It can be called after [createAudioEffectPlayer]. Restrictions: None.

    Returns number

    Audio effect player index.

Abstract getTotalDuration

  • getTotalDuration(audioEffectID: number): Promise<number>
  • Get the total duration of the specified audio effect resource.

    Available since: 1.16.0 Description: 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. Restrictions: It can be called after [createAudioEffectPlayer]. Related APIs: [start], [loadResource].

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    Returns Promise<number>

    Unit is millisecond.

Abstract loadResource

  • Load audio effect resource.

    Available since: 1.16.0 Description: 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]. 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.

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    • path: string

      the absolute path of the audio effect resource and cannot be null or "".
      Value range: "assets://"、"ipod-library://" and network url are not supported.

    Returns Promise<ZegoAudioEffectPlayerLoadResourceResult>

    Result for audio effect player loads resources

Abstract off

  • off<AudioEffectPlayerEventType>(event: AudioEffectPlayerEventType, callback: undefined | ZegoAudioEffectPlayerListener[AudioEffectPlayerEventType]): void
  • Unregister the event handler of mediaplayer

    Type parameters

    Parameters

    • event: AudioEffectPlayerEventType

      Event type.

    • callback: undefined | ZegoAudioEffectPlayerListener[AudioEffectPlayerEventType]

      Call back.

    Returns void

Abstract on

  • on<AudioEffectPlayerEventType>(event: AudioEffectPlayerEventType, callback: ZegoAudioEffectPlayerListener[AudioEffectPlayerEventType]): void
  • Register the event handler of mediaplayer

    Type parameters

    Parameters

    • event: AudioEffectPlayerEventType

      Event type.

    • callback: ZegoAudioEffectPlayerListener[AudioEffectPlayerEventType]

      Call back.

    Returns void

Abstract pause

  • pause(audioEffectID: number): Promise<void>
  • Pause playing audio effect.

    Available since: 1.16.0 Description: Pause playing the specified audio effect [audioEffectID]. When to call: The specified [audioEffectID] is [start]. Restrictions: None.

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    Returns Promise<void>

Abstract pauseAll

  • pauseAll(): Promise<void>
  • Pause playing all audio effect.

    Available since: 1.16.0 Description: Pause playing all audio effect. When to call: It can be called after [createAudioEffectPlayer]. Restrictions: None.

    Returns Promise<void>

Abstract resume

  • resume(audioEffectID: number): Promise<void>
  • Resume playing audio effect.

    Available since: 1.16.0 Description: Resume playing the specified audio effect [audioEffectID]. When to call: The specified [audioEffectID] is [pause]. Restrictions: None.

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    Returns Promise<void>

Abstract resumeAll

  • resumeAll(): Promise<void>
  • Resume playing all audio effect.

    Available since: 1.16.0 Description: Resume playing all audio effect. When to call: It can be called after [pauseAll]. Restrictions: None.

    Returns Promise<void>

Abstract seekTo

  • Set the specified playback progress.

    Available since: 1.16.0 Description: Set the specified audio effect playback progress. Unit is millisecond. When to call: The specified [audioEffectID] is[start], and not finished. Restrictions: None.

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    • millisecond: number

      Point in time of specified playback progress.

    Returns Promise<ZegoAudioEffectPlayerSeekToResult>

    Result for audio effect player seek to playback progress

Abstract setVolume

  • setVolume(audioEffectID: number, volume: number): Promise<void>
  • Set volume for a single audio effect. Both the local play volume and the publish volume are set.

    Available since: 1.16.0 Description: 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]. Restrictions: None.

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    • volume: number

      Volume.
      Value range: The range is 0 ~ 200.
      Default value: The default is 100.

    Returns Promise<void>

Abstract setVolumeAll

  • setVolumeAll(volume: number): Promise<void>
  • Set volume for all audio effect. Both the local play volume and the publish volume are set.

    Available since: 1.16.0 Description: 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]. Restrictions: None.

    Parameters

    • volume: number

      Volume.
      Value range: The range is 0 ~ 200.
      Default value: The default is 100.

    Returns Promise<void>

Abstract start

  • Start playing audio effect.

    Available since: 1.16.0 Description: 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]. Restrictions: None.

    Parameters

    • audioEffectID: number

      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: undefined | string

      The absolute path of the local resource.
      Value range: "assets://"、"ipod-library://" and network url are not supported. Set path as null or "" if resource is loaded already using [loadResource].

    • config: undefined | ZegoAudioEffectPlayConfig

      Audio effect playback configuration.
      Default value: Set null will only be played once, and will not be mixed into the publishing stream.

    Returns Promise<void>

Abstract stop

  • stop(audioEffectID: number): Promise<void>
  • Stop playing audio effect.

    Available since: 1.16.0 Description: Stop playing the specified audio effect [audioEffectID]. When to call: The specified [audioEffectID] is [start]. Restrictions: None.

    Parameters

    • audioEffectID: number

      ID for the audio effect.

    Returns Promise<void>

Abstract stopAll

  • stopAll(): Promise<void>
  • Stop playing all audio effect.

    Available since: 1.16.0 Description: Stop playing all audio effect. When to call: Some audio effects are Playing. Restrictions: None.

    Returns Promise<void>

Abstract unloadResource

  • unloadResource(audioEffectID: number): Promise<void>
  • Unload audio effect resource.

    Available since: 1.16.0 Description: 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. Restrictions: None. Related APIs: [loadResource].

    Parameters

    • audioEffectID: number

      ID for the audio effect loaded.

    Returns Promise<void>

Generated using TypeDoc