如何修改我的 VideoView 中显示的控件?
我有一个由简单 MediaController 控制的 VideoView,我想修改其控件。目前,它显示了一个搜索栏、快进和快退按钮以及播放/暂停。我想将其范围缩小到仅具有播放和暂停按钮,因为我正在播放的流或多或少是实时的。如何修改现有的控件?这是我当前在 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();
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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法修改
MediaController
中存在的控件,但您可以创建自己的控制器并使用它来代替MediaController
。我在这个古老的项目中做到了这一点。You cannot modify the controls that are present in
MediaController
, but you can create your own controller and use that instead ofMediaController
. I did that in this ancient project.