Returning to application after videoplayback
I have an application that has a list of videos with a play button. When I click on video, a separate activity is called through intent. When the video is finished, it remains there and it doesn't go back to the original application unless I press back button. Is there any way in which the application returns back to the main activity after the video playback is finished? Here is the code for my video creation
public void onCreate(Bundle onSavedInsance) {
super.onCreate(onSavedInsance);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.videoview);
Intent i = getIntent();
Bundle extras = i.getExtras();
filename = extras.getString("videofilename");
mVideoView = (VideoView) findViewById开发者_Go百科(R.id.VideoView);
mc = new MediaController(this);
mVideoView.setMediaController(mc);
mc.setAnchorView(mVideoView);
mVideoView.setMediaController(mc);
mVideoView.setVideoPath(filename);
//mVideoView.setVideoPath(video.getAbsolutePath());
mVideoView.requestFocus();
mVideoView.start();
}
If you are using a VideoView, you can add a listener to determine when the video has finished playing:
mVideoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
finish();
}
});
精彩评论