hobgillin
hobgillin

Reputation: 63

Control the playback speed of Android MediaPlayer

I'm using MediaPlayer to play back some videos in an Android application, and they are noticeably faster on my device as when viewed on a computer.

Is there any way to control the playback speed of these videos in order to slow them down?

Upvotes: 6

Views: 7258

Answers (1)

Shishir Gupta
Shishir Gupta

Reputation: 1582

Beginning API 23, MediaPlayer can set playback speed using this method.

Class MediaPlayer

public void setPlaybackParams (PlaybackParams params) Added in API level 23

Sets playback rate using PlaybackParams. Parameters params PlaybackParams: the playback params. Throws IllegalStateException if the internal player engine has not been initialized. IllegalArgumentException if params is not supported.

Sample code:

MediaPlayer mp = ...; //Whatever
float speed = 0.75f;     
mp.setPlaybackParams(mp.getPlaybackParams().setSpeed(speed));

For API < 23, refer to this SO question.

Upvotes: 9

Related Questions