Adding additional methods to MediaController buttons
<p>I have a VideoView which plays a video and I call </p>

<p><code>videoPlayer.setMediaController(new MediaController(this));</code> </p>

<p>to show the media controller buttons (play, pause, forward, backward).
The question is how am I able to add additional methods when I click the play or pause button of the <code>MediaController</code>?</p>

<p>Here's my class:</p>

<pre><code>public class VideoPlayer extends Activity implements OnCompletionListener {
    private String filename;

    private VideoView videoPlayer;
    private MediaPlayer mediaplayer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.video_player);

        System.gc();
        Intent i = getIntent();
        Bundle extras = i.getExtras();
        filename = extras.getString("video_url");

        System.out.println(filename);

        videoPlayer = (VideoView) findViewById(R.id.videoPlayer);
        videoPlayer.setOnCompletionListener(this);
        videoPlayer.setKeepScreenOn(true);
        videoPlayer.setVideoPath(filename);
        videoPlayer.setMediaController(new MediaController(this));
        videoPlayer.requestFocus();
        videoPlayer.start();

        mediaplayer = new MediaPlayer();
        mediaplayer = MediaPlayer.create(
                this,
                Uri.parse("android.resource://" + getPackageName() + "/"
                        + R.raw.alo));
        mediaplayer.start();

    }

    /** This callback will be invoked when the file is finished playing */
    @Override
    public void onCompletion(MediaPlayer mp) {
        // Statements to be executed when the video finishes.
        this.finish();
    }

    /** Use screen touches to toggle the video between playing and paused. */
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            if (videoPlayer.isPlaying()) {
                videoPlayer.pause();
                mediaplayer.pause();
            } else {
                videoPlayer.start();
                mediaplayer.start();
            }
            return true;
        } else {
            return false;
        }
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }   
}
</code></pre>
