ANDROID FAQ: How can the playback rate be adjusted in the Android SDK?(Android v4)

Answer: Use the playbackRates object.


You can use the playbackRates object to adjust the playback rate:

  1. Create a playbackRates object.
  2. Use PlayerConfig.Builder() to add the playbackRates object to the PlayerConfig object.

double[] playbackRates = new double[] { 0.5, 1, 2 };

// To setup custom playback rates
PlayerConfig playerConfig = new PlayerConfig.Builder()
              .playbackRates(playbackRates)
              .build();
     
getPlayer().setup(playerConfig);

Methods and Callbacks

Playback API

MethodDescription
PlayerState getState()Returns the player's current playback state
void play()Starts playback
void pause()Pauses playback
void stop()Stops the player and unloads the currently playing media file
void seek(double position)Seeks the currently playing media to the specified position, in seconds
double getPosition()Returns the current playback position in seconds
double getDuration()Returns the duration of the current media in seconds
void next()Tells JWP to immediately play the next playlist item
void playlistItem(int index)Start playback of the playlist item at the specified index
CallbackDescription
onPlay(PlayEvent playEvent)Fired when the player enters the PLAYING state
onPause(PauseEvent pauseEvent)Fired when the player enters the PAUSED state
onBuffer(BufferEvent bufferEvent)Fired when the player enters the BUFFERING state
onIdle(IdleEvent idleEvent)Fired when the player enters the IDLE state
onFirstFrame(FirstFrameEvent firstFrameEvent)Fired when playback begins
onSeek(SeekEvent seekEvent)Fired after a seek has been requested either by scrubbing the controlbar or through the API
onSeeked(SeekedEvent seekedEvent)Fired after a seek operation has completed
onTime(TimeEvent timeEvent)While the player is playing, this event is fired as the playback position gets updated.

This may occur as frequently as 10 times per second.
onDisplayClick(DisplayClickEvent displayClickEvent)Fired when the user clicks or taps the video display

Quality API

The QualityLevel class represents a quality variant in a HLS or DASH stream. Quality levels are sent to the developer via the onQualityLevels() callback.

MethodDescription
List<QualityLevel> getQualityLevels()Returns a list of the currently available quality levels
int getCurrentQuality()Returns the index of the current quality level in the List returned by getQualityLevels()
setCurrentQuality(int index)Sets the quality level to the provided index
CallbackDescription
onLevels(LevelsEvent levelsEvent)Fired when the list of quality levels is updated

This happens shortly after an item starts playing.
onLevelsChanged(LevelsChangedEvent levelsChangedEvent)Fired when the active quality level is changed

This happens in response to a user clicking the control bar or a call to setCurrentQuality().