Naftuli Kay
Naftuli Kay

Reputation: 91620

How can I modify what controls show up for my VideoView?

I have a VideoView controlled by a simple MediaController that I'd like to modify the controls for. Currently, it shows a seek bar, fast-forward and rewind buttons, and play/pause. I'd like to narrow this down to simply having play and pause buttons, as the stream I'm playing is more or less live. How can I modify the controls present? This is my current code in onCreate:

this.setContentView(R.layout.videoplayer);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        WindowManager.LayoutParams.FLAG_FULLSCREEN);

this.videoView = (VideoView)this.findViewById(R.id.videoview);
this.mediaController = new MediaController(this);
this.mediaController.setAnchorView(this.videoView);

Uri uri = Uri.parse(this.getIntent().getStringExtra("uri"));

this.videoView.setMediaController(this.mediaController);
this.videoView.setVideoURI(uri);

this.videoView.setOnPreparedListener(new OnPreparedListener() {
    @Override public void onPrepared(MediaPlayer mp) {
        findViewById(R.id.video_loading_spinner).setVisibility(View.GONE);
    }
});

this.videoView.setOnErrorListener(new OnErrorListener() {
    @Override public boolean onError(MediaPlayer mp, int what, int extra) {
        showDialog(VIDEO_FAILED);
        return true;
    }
});

//this.videoView.setOnCompletionListener(new OnCompletionListener() {
//  @Override public void onCompletion(MediaPlayer mp) {
//      showDialog(VIDEO_COMPLETE);
//  }
//});

this.videoView.start();

Upvotes: 1

Views: 824

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006604

You cannot modify the controls that are present in MediaController, but you can create your own controller and use that instead of MediaController. I did that in this ancient project.

Upvotes: 1

Related Questions