android - VideoView 闪烁问题

标签 android android-videoview

我在使用 VideoView 时遇到了奇怪的闪烁问题。当 Activity 开始时,它会导致一秒钟的轻微闪烁。然后,视频开始。它在视频的顶部和底部显示 2 条黑线。请参阅下面的快照。

check snap shot

我已经在 2 台设备上测试了我的应用程序

1) 三星n-8000(平板)

2)联想a-800

video.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#ffffff"
 android:gravity="center">

 <VideoView 
    android:id="@+id/vvSplash"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="#00ffffff">
</VideoView>

</LinearLayout>

Activity 代码:

private VideoView vd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.video);
    vd = (VideoView) findViewById(R.id.vvSplash);
    playVideo();
}

private void playVideo() {
    Uri uri = Uri.parse("android.resource://" + getPackageName() +"/"+ R.raw.intro);
    vd.setVideoURI(uri);
    vd.setMediaController(null);
    vd.start();     
}

如有任何帮助,我们将不胜感激。谢谢你。

最佳答案

虽然听起来很荒谬,但答案就在这里:

我重复这个解决方案,感谢那些发现的人:

<SurfaceView
    android:layout_width="0px"
    android:layout_height="0px"
    android:visibility="gone" />

非常重要将表面 View 添加到 Activity 中的 Root View ,而不是直接父 View 。否则它不会工作。

关于android - VideoView 闪烁问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17587476/

相关文章:

java - 未找到 com.google.common.util.concurrent.ListenableFuture 的 Android Studio 类文件

android - PrivacyListManager.getInstanceFor 在 android aSmack 中为 NULL

android - isMicrophoneMute() 和 setMicrophoneMute() 使 Android 应用程序崩溃

java.io.FileNotFoundException : No content provider: 错误

Android检测来自URL的视频是否为纵向

Android:无法播放mp4视频

android - 几个小时后应用程序未在 PlayStore 上显示

android - 我可以从哪里更改已在 App Store 中的应用程序的刷新率?

java - 从SD卡播放视频并使用videoView循环播放视频

android - 简单的安卓视频播放器