android - 如何在视频 View 上强制进行 alpha 混合

标签 android video overlay

我有一个 Android 应用程序,它显示一个 VideoView,前面有按钮。在目标设备上,按钮会正确显示在顶部,直到 VideoView 重新绘制自身(例如,从另一个 Activity 返回时)。然后按钮被 VideoView 隐藏。

这不会发生在其他两个设备上,据我所知,这不是 Android 中的预期行为。我相信这与我在设备上看到的错误有关。标签是'TIOverlay',文本是

'static void overlay_control_context_t::overlay_destroyOverlay( overlay_control_device_t*, overlay_t*) : Lets Switch off Alpha Blending'

有什么方法可以强制 VideoView 重新计算它的 alpha 值吗?由于初始 View 是正确的,我认为它只是在重绘时没有考虑完整布局。

这是我的 VideoView 初始化代码:

    //set up video
    this.videoView = (VideoView) findViewById(R.id.introVideoView);
    videoView.setZOrderOnTop(false);


    //create intro movie and begin playing
    String uri = "android.resource://"+getPackageName()+"/"+R.raw.movie;
    videoView.setVideoURI(Uri.parse(uri));
    //set to looping
    videoView.setOnPreparedListener(new OnPreparedListener(){

    @Override
    public void onPrepared(MediaPlayer mp)
    {
    mp.setLooping(true);
    }});
    videoView.start();

编辑

我用来在视频 View 前面显示按钮的布局是:



<视频 View 
    android:id="@+id/introVideoView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

<图片按钮
    android:id="@+id/exitDemoButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    机器人:layout_alignParentBottom =“真”
    机器人:layout_alignParentRight =“真”
    android:contentDescription="退出演示>>"
    android:onClick="exitDemo"
    android:background="#00000000"
    android:src="@drawable/exit_selector"/>


<线性布局
    android:id="@+id/buttonLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="真"
    android:orientation="水平">
 <图片按钮
        android:id="@+id/resumeVideoButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onResumeClicked"
        android:contentDescription="恢复视频"
        android:background="#00000000"
        android:src="@drawable/resume_selector"/>
    <图片按钮
        android:id="@+id/guidedTourButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onTourClicked"
        android:contentDescription="导览"
        android:background="#00000000"
        android:src="@drawable/tour_selector"/>

最佳答案

我确实找到了解决方案。看来是因为我正在从具有类似 VideoView 的其他 Intent 切换回此 View ,我需要在切换到另一个 Intent 或从该 Intent 返回到这个 Intent 之前使用 VideoView.suspend() 暂停视频。我推测这是因为硬件只有一个良好的硬件视频缓冲区,它保留了我刚刚留在缓冲区中的 VideoView

关于android - 如何在视频 View 上强制进行 alpha 混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9642401/

相关文章:

video - 此 ffmpeg 命令中的倒数第二个参数有什么作用?

iphone - 嵌入视频以在 iPhone 上播放?

android - ts 文件中的叠加图像

android - 二进制XML文件第14行:膨胀自定义ViewGroup类时出错

Android 选项卡布局帮助

android - Small Style Custom rating bar (readonly custom rating bar)

ios - 有哪些替代方法可以将大量教学视频捆绑到健身应用程序中?

c# text/winForm 覆盖 xfire、PIX、steam、fraps 等视频游戏

ios - 将来自摄像头的视频 + 自定义 View 捕获到单个视频文件中

android - 为什么 "MediaCodec CodecException"中的 "queueInputBuffer"只发生在 Android API 29 上?