在Android VideoView绘制覆盖(HUD)? [英] Draw overlay (HUD) on Android VideoView?

查看:998
本文介绍了在Android VideoView绘制覆盖(HUD)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绘制一个自定义视图的 HUD

I have a custom view that draws HUD:

下面是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <VideoView
        android:id="@+id/videoView1"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <com.widgets.HUD
            android:id="@+id/hud"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />

</FrameLayout>

public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.hud_fragment, container, false);

    frameLayout = (FrameLayout) view.findViewById(R.id.frameLayout);

    hudWidget = (HUD) view.findViewById(R.id.hudWidget);

    videoView = (VideoView) view.findViewById(R.id.videoView1);
    videoView.setVideoURI(Uri.parse("http://88.150.210.138:5001/spor"));
    videoView.start();

    frameLayout.removeView(hudWidget);
    frameLayout.addView(hudWidget);
    hudWidget.bringToFront();

    return view;
}

我上播放的 RTSP 流我的 VideoView 一旦视频开始播放它看起来像:

I play an RTSP stream on my VideoView as soon as the video starts playing it looks like that:

我怎么能强迫HUD借鉴的 VideoView 热门? HUD延伸SurfaceView

How can i force the HUD to draw on top of the VideoView? HUD extends SurfaceView

  • 的项目中,我尝试添加的VideoView是 DroidPlanner 你可以尝试克隆看看这个问题。 (需要手动添加VideoView,因为它不是在回购)。

  • The project I'm trying to add the the VideoView is DroidPlanner You can try cloning and see the problem. (Need to add the VideoView manually because it's not in the repo).

推荐答案

我发现你的问题的答案:的 VideoView在SurfaceView的顶部的SurfaceView和VideoView都是表面的观点,并没有得到支持,因为2.0重叠这些旧版本的Andr​​oid,但可用。

I found the answer for your question: VideoView on top of SurfaceView The SurfaceView and the VideoView are both surface views and it was not supported to overlap these in old versions of Android but available since 2.0.

您需要做的:

  1. 将像素格式为透明的,以便让通过接口
  2. 视频大放异彩

hudWidget.getHolder()和setFormat(PixelFormat.TRANSPARENT);

  1. 将HUD表面是一个媒体覆盖。

hudWidget.setZOrderMediaOverlay(真);

  1. 创建一个新的表面,并设置为显示的MediaPlayer的播放视频。

有一个拉请求,在那里你可以尝试这些。 https://github.com/arthurbenemann/droidplanner/pull/247

There is a pull request where you can try these. https://github.com/arthurbenemann/droidplanner/pull/247

这带来了解决方案的线程:的https://groups.google.com/forum/?fromgroups#!msg/android-developers/nDNQcceRnYA/ps9wTBfXIyEJ

The thread that brought the solution: https://groups.google.com/forum/?fromgroups#!msg/android-developers/nDNQcceRnYA/ps9wTBfXIyEJ

这篇关于在Android VideoView绘制覆盖(HUD)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆