how to stop video player after it has played a video in android
<p>I'm trying to play a video from a website in an android app. I got the video to play but there are two things I'm concerned about:</p>

<ol>
<li><p>When I rotate the phone while the video is playing, it reloads the video and starts from the beginning again.</p></li>
<li><p>After the video has ended it seems like it is still doing something and I can't hit the back button and return to previous activity.</p></li>
</ol>

<p><strong>Java file:</strong></p>

<pre><code>public class IntroVideo extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.intro_video);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    try {

        String link = "http://northeastvision.org/vids/tube_rush.mp4";
        final VideoView video = (VideoView) findViewById(R.id.videoDisplay);
        final ProgressDialog mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setMessage("Loading video Please wait...");
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();


        video.setMediaController(new MediaController(IntroVideo.this));
        Uri uri = Uri.parse(link);
        video.setVideoURI(uri);

        video.setOnPreparedListener(new OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mp) {

                video.start();
                mProgressDialog.dismiss();
            }
            });

    }
    catch (Exception e) {
        Toast.makeText(this, "Error Connecting!", Toast.LENGTH_SHORT).show();
    }
    }
</code></pre>

<p><strong>Layout</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" &gt;

&lt;VideoView
        android:id="@+id/videoDisplay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         /&gt;

&lt;/RelativeLayout&gt;
</code></pre>
