gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 18:04:57 24 4
gpt4 key购买 nike

我正在尝试从 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 控件不显示视频,只播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13864118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com