如何为VideoView或MediaController制作自定义按钮/进度条?

时间:2012-07-02 06:35:44

标签: android custom-controls media-player android-videoview

我想用自定义设计创建MediaPlayer,但是怎么做我找不到。我制作流媒体播放器:

...
mVideoView = (VideoView) findViewById(R.id.vedio_view);
mBtnHttp = (Button) findViewById(R.id.btn_http);
mBtnHttp.setOnClickListener(this);
mMediaController = new MediaController(this);
...
public void onClick(View v) {
    mVideoView.setVideoURI(Uri.parse(uri));
    mVideoView.start();
    mVideoView.requestFocus();
    mMediaController.show();
    }
...

请帮帮我。我在stackoverflow中发现了很多主题,但问题没有解决! 提前谢谢!

1 个答案:

答案 0 :(得分:0)

或者,您可以使用Exoplayer播放视频

dependencies {
   [...]

implementation 'com.google.android.exoplayer:exoplayer-core:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.7.3'

}

使用PlayerView代替视频视图,并在app:controller_layout_id attr中提供custom_playback_control的路径

  <com.google.android.exoplayer2.ui.PlayerView  
   android:id="@+id/video_view"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   app:controller_layout_id="@layout/custom_playback_control"/>

https://codelabs.developers.google.com/codelabs/exoplayer-intro/#6