- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 VideoView
似乎只有在它是我的 FrameLayout
的唯一子项时才可见。当有第二个 child 时——一个 SurfaceView
(即使 VideoView
是在之后创建的,给它一个更高的 z-index)——那么 VideoView
不再可见。
我有一个 Vitamio 的 VideoView
的扩展:
public class AnimationCanvas extends VideoView{
public static AnimationCanvas animationCanvas;
public AnimationCanvas(Context context, AttributeSet attrs){
super(context, attrs);
animationCanvas = this;
setVideoURI(Uri.parse(MainActivity.toRightPath));
requestFocus();
start();
this.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_UP:
System.out.println("UP");
setVideoURI(Uri.parse(MainActivity.animationFilePath));
requestFocus();
start();
break;
case MotionEvent.ACTION_DOWN:
System.out.println("Down");
break;
}
return true;
}
});
}
这是 main.xml 文件:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<com.temporary.alexcameronelijahapp.gui.MainCanvas
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.temporary.alexcameronelijahapp.gui.AnimationCanvas
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
当我删除或注释掉 main.xml 文件的 MainCanvas
View 时,AnimationCanvas
工作正常(这些行):
<com.temporary.gui.MainCanvas
android:layout_width="match_parent"
android:layout_height="match_parent" />
我的印象是,在 FrameLayout
中,Z 索引是按照它们添加到布局中的顺序分配的(最后添加的具有最高的 z 索引) .但是,只要 MainCanvas
也存在,AnimationCanvas
就不可见...
有什么想法吗?
编辑: 很高兴知道我实际上在我的 MainCanvas
实例上绘制了许多位图。
其次,如果我在 AnimationCanvas
的 xml 代码中设置 android:background="#000000"
,它就会在 MainCanvas
上可见>,但视频本身仍然不会显示(好像黑色背景以某种方式掩盖了视频?)
编辑 #2: 我相信我已经找到了问题,但仍然没有解决方案。当我在我的 MainCanvas
类中注释掉我的绘画方法时,这意味着没有位图被绘制到 Canvas 上,然后 AnimationCanvas
是可见的。就好像,即使 AnimationCanvas
位于 MainCanvas
之上,MainCanvas
的锁定 Canvas 也不知何故位于 之上AnimationCanvas 的
VideoView Canvas 。
最佳答案
SurfaceView
在可见性和 z 顺序等方面的行为与其他小部件不同。有关详细信息,请参阅 GL Surface and Visibility: Gone .最重要的是,他们只是忽略了可见性。另请注意,VideoView
只是 SurfaceView 的另一个示例。
尝试上面帖子中的建议之一。在您的情况下,您还可以尝试使用相同的 SurfaceView
作为绘图和视频的目标。
关于android - 当放置在 SurfaceView 上时,VideoView 在 FrameLayout 中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31506912/
这是我的代码 fragment ,我想在其中播放来自服务器的视频 private void PlayVideo() { try { getWindow().setFormat(
我对 Android Studio 相当陌生,正在尝试一个项目,其中基于点击事件,videoView(2 个视频)从 vid1 变为 vid2,vid2 变为 vid1 等等,并且两者同时播放且长度相
我感兴趣的是能够在 VideoView B 播放时“预缓冲”VideoView A。这可能吗? 我有两个 VideoView 实例。 在给定时间只会显示一个 VideoView,占据手机的整个屏幕。
我最初隐藏了 VideoView,当加载视频时,我正在显示 VideoView。但是,如果 VideoView 最初是 invisible,则永远不会调用 onPrepared。但是,如果 Video
我正在尝试将视频添加到我的应用程序中。视频本地存储在 res/raw 中。我不知道为什么会出现“videoView.setVideoURI("uri");”错误和“videoView.start();
我正在创建一个应用程序来在 Amazon FireTV 机顶盒上播放各种类型的视频。如果我使用默认的 Android VideoView 播放视频。如果我使用 Vitamio 的 VideoView,
我必须在 android 上强制使用 videoView.setZOrderOnTop(true)。但是在使用它之后,我无法在 videoView 上显示按钮。即使在设置 videoView.setZ
我正在尝试制作一个带有 VideoView 的视频播放器,它支持在其上使用 TextView 的字幕。 我已经解析了字幕,但现在我需要一个在每次帧更改时运行的事件,以使用当前播放位置更新字幕。 我尝试
我有一个 *.mp4文件,持续时间为 2 分钟。现在它有从 30 seconds upto 1.10 min 开始的音轨. 30s 之前的其余部分及之后 1.10min为空白。 现在的问题是当我尝试在
我想在我的started_activity背景下运行视频 View 。但加载失败。 屏幕是黑色的,如果我导航或将我的页面推送到另一个页面两次,它将显示应用程序没有响应警报。 我遵循这个视频教程:htt
我在这里使用imageView,当我点击它时应该向我显示一个视频(线性10),这个视频大约4秒,我需要一个代码,当我再次点击imageView 视频应该再次开始播放,每次我单击 imageView 时
我的一个 Activity 中有一个 VideoView,如果我尝试按后退 Button,它不会将我带到之前的 Activity 并且它也不会在日志猫中给出任何错误消息。 我尝试覆盖 onBackPr
我正在制作一个视频播放器,它将从服务器流式传输视频。我已经检查过,视频网址正确且有效!已经很晚了,所以我可能错过了一些东西,但为什么会这样 VideoView videoView = (VideoVi
我有一个应用程序正在从另一个充当服务器的应用程序接收视频文件。当应用程序保存在套接字上接收到的文件时,视频流开始播放该文件(正在构建中)。在代码示例中,按下 btnStream 后,按下 btnPla
我有一个视频 View ,我希望能够播放/暂停和全屏显示。我无法让视频显示控件。 private fun showVideo() { isLottieVisible = false
我制作了一个应用程序,我想在其中播放原始文件夹中的 SWF 文件。 当我运行应用程序时,它会显示 Sorry, the video cant be played. 我不知道如何纠正它。我已经在设备上安
有谁知道为什么我的应用程序在打印出 VideoView 中的变量时只返回错误的值? @Override public void onCreate(Bundle savedInstanceState)
我想编写在单击按钮时播放视频的代码。我无法显示视频。当我点击按钮播放时,模拟器停止工作。 public class Video extends Activity{ private static fin
所以我正在尝试在 android 中播放基本的 avi 视频,它似乎在 Windows Media Player、VLC 等上运行良好,所以它看起来不需要任何复杂的编解码器。我的应用程序中有一个视频
我正在开发具有两个 View 的应用程序,一个是 UI,另一个是 VideoView。在某些事件发生之前使用 UI 线程,然后我想将 setContentView 设置为 VideoView,但是在将
我是一名优秀的程序员,十分优秀!