Interface AudioPlayer
-
- All Implemented Interfaces:
public interface AudioPlayerAudio player used to play audio messages.
-
-
Method Summary
Modifier and Type Method Description abstract UnitregisterOnAudioStateChange(Integer audioHash, Function1<AudioState, Unit> onAudioStateChange)Subscribing for audio state changes for the audio of the hash abstract UnitregisterOnProgressStateChange(Integer audioHash, Function1<ProgressData, Unit> onProgressDataChange)Subscribing for progress changes for the audio of the hash. abstract UnitregisterOnSpeedChange(Integer audioHash, Function1<Float, Unit> onSpeedChange)Subscribing for speed changes for the audio of the hash. abstract UnitregisterTrack(String sourceUrl, Integer audioHash, Integer position)abstract UnitclearTracks()abstract Unitprepare(String sourceUrl, Integer audioHash)abstract Unitplay(String sourceUrl, Integer audioHash)Plays an audio track with sourceUrl. abstract Unitpause()Pauses the current song. abstract Unitresume(Integer audioHash)abstract UnitresetAudio(Integer audioHash)abstract UnitseekTo(Integer positionInMs, Integer audioHash)Seeks the audio track of the audio hash to the millisecond position. abstract UnitstartSeek(Integer audioHash)Informs the player that seek has started. abstract UnitchangeSpeed()Changes the speed of reproduction. abstract FloatcurrentSpeed()Current speed of reproduction. abstract IntegergetCurrentPositionInMs(Integer audioHash)Returns the current position of the audio track in milliseconds. abstract UnitremoveAudio(Integer audioHash)Removes the current audio form the reproduction queue and removes the listeners abstract UnitremoveAudios(List<Integer> audioHashList)Removes the current audios form the reproduction queue and removes the listeners abstract Unitreset()Resets the player to the initial state and removes all audios. abstract Unitdispose()Disposes the MediaPlayer and remove all audios. abstract AudioStategetCurrentState()Current state of the current audio. abstract IntegergetCurrentPlayingId()The identifier of the current audio track. -
-
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 trackonAudioStateChange- 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 trackonProgressDataChange- 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 trackonSpeedChange- The listener of the speed change.
-
registerTrack
abstract Unit registerTrack(String sourceUrl, Integer audioHash, Integer position)
-
clearTracks
abstract Unit clearTracks()
-
play
abstract Unit play(String sourceUrl, Integer audioHash)
Plays an audio track with sourceUrl.
- Parameters:
sourceUrl- the URL of the audio track
-
resetAudio
abstract Unit resetAudio(Integer audioHash)
-
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
-
getCurrentState
abstract AudioState getCurrentState()
Current state of the current audio.
-
getCurrentPlayingId
abstract Integer getCurrentPlayingId()
The identifier of the current audio track. If there is no current audio track, it returns -1.
-
-
-
-