【问题标题】:How make custom buttons/progressbar for VideoView or MediaController?如何为 VideoView 或 MediaController 制作自定义按钮/进度条?
【发布时间】:2012-07-02 06:35:43
【问题描述】:

我想创建具有自定义设计的 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中找到了很多主题,但问题没有解决! 提前致谢!

【问题讨论】:

  • 好的,你想在媒体播放器中拥有自己的控件还是什么?
  • 是的,完全正确。你知道吗,这是怎么做到的?
  • 这是一个 MediaController 自定义示例:stackoverflow.com/questions/12482203/…

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


【解决方案1】:

您也可以使用 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多