- I am working on a project which needs to play video in slow motion.
- I am well aware that Android doesn't provide these functionality.
- I found PVPlayer Engine and libVLC which possessed these capabilities, but i didn't found any tutorial or proper documentation of including them in the android project and using them.
- So i tried doing this by using Runnable
and Handler
, it was successful in slowing down the video but they possessed jerks during playing.
public class MainActivity extends Activity {
VideoView vx;
Button mbutt;
Handler h ;
int curr = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
h = new Handler();
vx = (VideoView)findViewById(R.id.videoView);
mbutt = (Button)findViewById(R.id.button_Play);
vx.setVideoPath("/mnt/sdcard/you.mp4");
mbutt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
vx.start();
}
});
Runnable r = new Runnable() {
@Override
public void run() {
if (vx != null) {
if (vx.isPlaying()){
vx.pause();
}
else{
vx.start();
}
}
h.postDelayed(this, 50);
}
};
h.postDelayed(r, 200);
}
}
- I have tried various combination of pause time and playing time to remove the jerks but all in vain, can anyone help me in removing these jerks so it plays a nice slow motion video or suggest another easy to integrate library into my android project.
Thanks in advance......