直接致电
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<com.zuji.entrance.widget.MainPageVideoView
android:id="@+id/video_main_page"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>

黑屏故障排除:
要解决此问题android videoview,您需要等待视频实际渲染,然后再删除VideoView的背景. 最终的解决方案是在onPrepared回调中添加setOnInfoListener侦听器android videoview,并在此侦听器中清除VideoView的背景. 具体修改如下:
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setOnInfoListener(new MediaPlayer.OnInfoListener() {
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START)
videoView.setBackgroundColor(Color.TRANSPARENT);
return true;
}
});
此代码的键是MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START变量. Android SDK中给出的注释是: 此状态指示显示了要渲染的视频的第一帧,即,此时视频帧实际上已显示在屏幕上. 上.
但是,此变量是在4.1版中引入的,在4.1之前的版本中仍不支持此变量. 只能通过方法3暂时优化4.1之前的版本.
谢谢:
用于本地视频短黑屏的Android VideoView解决方案
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/bofangqi/article-149349-2.html
不能多吃
我要被帅晕了o