Reputation: 753
I am doing android application related Video Player.I played Video but I want to do When Video complete,it resumption with automatically in application how can I do? I am Using VideoView in my appliation.
// Displays a video file.
VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
String uriPath = "android.resource://com.example.anket4dammy/"
+ R.raw.dunyagoz;
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int eventaction = event.getAction();
switch (eventaction) {
case MotionEvent.ACTION_DOWN:
// timer.cancel();
Intent intent = new Intent(getApplicationContext(),
MainActivity.class);
intent.putExtra("EXIT", false);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
break;
}
return true;
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
}
Upvotes: 0
Views: 1457
Reputation: 753
Try below code
// video finish listener
mVideoView
.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// not playVideo
// playVideo();
mp.start();
}
});
Upvotes: 1