Android videoview控件不显示视频,仅播放音频

Android videoview控件不显示视频,仅播放音频,第1张

概述我正在尝试从android中的url播放视频,为此,我在fragment类中使用videoview控件,但是在播放时没有视频输出,只有音频输出,视频为.mp4格式.我已经通过以下方式做到了-VideoViewvv;vv=(VideoView)view.findViewById(R.id.videoView1);Stringsrc="videopath";Uriuri=U

我正在尝试从android中的url播放视频,为此,我在fragment类中使用vIDeovIEw控件,但是在播放时没有视频输出,只有音频输出,视频为.mp4格式.我已经通过以下方式做到了-

  VIDeoVIEw vv;  vv=(VIDeoVIEw)vIEw.findVIEwByID(R.ID.vIDeoVIEw1);  String src="vIDeo path";  Uri uri=Uri.parse(src);     getActivity().getwindow().setFormat(PixelFormat.TRANSLUCENT);       MediaController mc=new MediaController(getActivity());  mc.setMediaPlayer(vv);  vv.setMediaController(mc);  vv.setVIDeoURI(uri);  vv.requestFocus();  vv.start();

这是我的xml代码

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:tools="http://schemas.androID.com/tools"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent"    androID:orIEntation="vertical"    androID:background="#303040" >    <relativeLayout        androID:layout_wIDth="230dp"        androID:layout_height="wrap_content" >        <TextVIEw            androID:ID="@+ID/headline"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_marginleft="100dp"            androID:layout_margintop="5dp"            androID:textcolor="#AFDEFE"            androID:textSize="14sp"            androID:textStyle="italic"            androID:typeface="serif" />        <com.facebook.Widget.ProfilePictureVIEw            androID:ID="@+ID/fbPic"            androID:layout_wIDth="72dp"            androID:layout_height="72dp"            androID:layout_alignParentleft="true"            androID:layout_alignParenttop="true"            androID:layout_margintop="5dp"            androID:layout_marginleft="20dp" >        </com.facebook.Widget.ProfilePictureVIEw>    </relativeLayout>    <com.facebook.Widget.Loginbutton            androID:ID="@+ID/loginbutton"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center_horizontal"            androID:layout_margintop="30dp" />    <button        androID:ID="@+ID/settingsbutton"        androID:layout_wIDth="111dp"        androID:layout_height="wrap_content"        androID:layout_gravity="center_horizontal"        androID:layout_margintop="32dp"        androID:text="Play" />    <VIDeoVIEw        androID:ID="@+ID/vIDeoVIEw1"        androID:layout_wIDth="200dp"        androID:layout_height="140dp"        androID:layout_marginleft="60dp"        androID:layout_margintop="10dp"        androID:keepScreenOn="true" /></linearLayout>

解决方法:

仅添加一行

vv.setZOrderOntop(true);
总结

以上是内存溢出为你收集整理的Android videoview控件不显示视频,仅播放音频全部内容,希望文章能够帮你解决Android videoview控件不显示视频,仅播放音频所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1095751.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存