Speed Control of Mediaplayer in Android

Speed Control of MediaPlayer in Android

The MediaPlayer does not provide this feature but SoundPool has this functionality.
The SoundPool class has a method called setRate (int streamID, float rate). If you are interested in the API have a look here.

This Snippet will work.

 float playbackSpeed=1.5f; 
SoundPool soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);

soundId = soundPool.load(Environment.getExternalStorageDirectory()
+ "/sample.3gp", 1);
AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
final float volume = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);

soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener()
{
@Override
public void onLoadComplete(SoundPool arg0, int arg1, int arg2)
{
soundPool.play(soundId, volume, volume, 1, 0, playbackSpeed);
}
});

How to adjust play speed of video on android?

Media player does not provide what you want.
You have to use some other android api.

check link. Speed Control of MediaPlayer in Android

Or you can use media player with PlaybackParams(added in 23 api)

https://developer.android.com/reference/android/media/PlaybackParams.html

Control the playback speed of video in android

No, you cannot change the playback rate by simply using VideoView. VideoView and MediaPlayer only provide limited media functions.

You have to use some third party library, e.g., PVPlayer, and implement that yourself.

That's also why good media players on Android are so valuable:)

How speed up a song playback

You can use PlaybackParams object to do that.

PlaybackParams pp = new PlaybackParams();

//speed *2
pp.setSpeed(2f);
//speed /2
pp.setSpeed(0.5f);

mp.setPlaybackParams(pp);

WARNING

You need Api 23 to do that (Android 6.0)



Related Topics



Leave a reply



Submit