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
How to Use Device Default Theme for App
How to Display Border to Imageview
How to Change the Background Color Around a Dialogfragment
How to Send Notification to Specific Users with Fcm
Android Take Screenshot via Code
Difference Between Content_Main.Xml and Activity_Main.Xml
How to Stop Other Apps Playing Music from My Current Activity
Android Linkify Text - Spannable Text in Single Text View - as Like Twitter Tweet
Play an Audio Clip Onto an Ongoing Call
Adt Doesn't Create Default Hello World But Command Line Does
How to Get All Child's Data in Firebase Database
Clear Text in Edittext When Entered
How to Simulate Accelerometer in Android Emulator
How to Tell Which App Was Selected by Intent.Createchooser
Programmatic Screencapture on Mobile Device
Android Gradle Build Error:(9, 0) Gradle Dsl Method Not Found: 'Compile()'
How to Rename a File on Sdcard with Android Application
Cannot Start Activity Background in Android 10 [ Android Q ]