Interface AudioPlayer

  • All Implemented Interfaces:

    
    public interface AudioPlayer
    
                        

    Audio player used to play audio messages.

    • Constructor Detail

    • Method Detail

      • registerOnAudioStateChange

         abstract Unit registerOnAudioStateChange(Integer audioHash, Function1<AudioState, Unit> onAudioStateChange)

        Subscribing for audio state changes for the audio of the hash

        Parameters:
        audioHash - the identifier of the audio track
        onAudioStateChange - The listener of the AudioState change.
      • registerOnProgressStateChange

         abstract Unit registerOnProgressStateChange(Integer audioHash, Function1<ProgressData, Unit> onProgressDataChange)

        Subscribing for progress changes for the audio of the hash. The progress is updated every 50ms

        Parameters:
        audioHash - the identifier of the audio track
        onProgressDataChange - The listener of the ProgressData change.
      • registerOnSpeedChange

         abstract Unit registerOnSpeedChange(Integer audioHash, Function1<Float, Unit> onSpeedChange)

        Subscribing for speed changes for the audio of the hash.

        Parameters:
        audioHash - the identifier of the audio track
        onSpeedChange - The listener of the speed change.
      • play

         abstract Unit play(String sourceUrl, Integer audioHash)

        Plays an audio track with sourceUrl.

        Parameters:
        sourceUrl - the URL of the audio track
      • pause

         abstract Unit pause()

        Pauses the current song.

      • seekTo

         abstract Unit seekTo(Integer positionInMs, Integer audioHash)

        Seeks the audio track of the audio hash to the millisecond position. If the hash is the same of the current playing audio track, the current audio track pauses.

        Parameters:
        positionInMs - the position in milliseconds.
        audioHash - the identifier of the audio track
      • startSeek

         abstract Unit startSeek(Integer audioHash)

        Informs the player that seek has started. This can be used to pause the current audio track when seek starts.

      • changeSpeed

         abstract Unit changeSpeed()

        Changes the speed of reproduction. Options are 1x, 1.5x and 2x

      • currentSpeed

         abstract Float currentSpeed()

        Current speed of reproduction. Options are 1x, 1.5x and 2x

      • getCurrentPositionInMs

         abstract Integer getCurrentPositionInMs(Integer audioHash)

        Returns the current position of the audio track in milliseconds.

        Parameters:
        audioHash - the identifier of the audio track
      • removeAudio

         abstract Unit removeAudio(Integer audioHash)

        Removes the current audio form the reproduction queue and removes the listeners

      • removeAudios

         abstract Unit removeAudios(List<Integer> audioHashList)

        Removes the current audios form the reproduction queue and removes the listeners

      • reset

         abstract Unit reset()

        Resets the player to the initial state and removes all audios.

      • dispose

         abstract Unit dispose()

        Disposes the MediaPlayer and remove all audios.

      • getCurrentPlayingId

         abstract Integer getCurrentPlayingId()

        The identifier of the current audio track. If there is no current audio track, it returns -1.