I have problems about how to implement PlaybackParams to set video speed:
public PlaybackParams getPlaybackParams ()
Added in API level 23
Gets the playback rate using PlaybackParams.
PlaybackParams setSpeed (float speed) //Sets the speed factor.
Returns:
the playback rate being used.
Throws IllegalStateException:
if the internal sync engine or the audio track has not been initialized.
This is my code:
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer mp)
{
mp.setPlaybackParams(new PlaybackParams().setSpeed(1.f));
if (mPlaybackState == PlaybackState.PLAYING) { mVideoView.start();}
}
});
You are getting an IllegalStateException while calling the 'setPlayParams' method, because you're not doing PlaybackParams params = mp.getPlaybackParams(), set the speed and then pass it to mp.setPlaybackParams()! Set the speed DIRECTLY while calling the mp.getPlayParams()!
MediaPlayer mp = ...;
float speed = 0.55f;
mp.setPlaybackParams(mp.getPlaybackParams().setSpeed(speed));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With