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

问题描述 投票:4回答:1

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

android custom-controls media-player android-videoview
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.