vv = (VideoView)this.findViewById(R.id.videoView1);
Uri uri = Uri.parse(url);
vv.setVideoURI(uri);
vv.start();
我使用VideoView播放网址视频。 像上面一样。 但是当我改变手机屏幕方向时。 它将重新加载所有视频。 如何改进程序到重装动作? 非常感谢。
答案 0 :(得分:2)
解决方案1 :(在大多数情况下,这有效..)
修改您的VideoView xml文件,例如
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true" />
</RelativeLayout>
解决方案2 ..
或处理活动中的方向变化,
对于AndroidManifest.xml中视频的活动标记:
android:configChanges="orientation"
所以整条线看起来像这样:
<activity android:name="<Your video avtivityy>" android:configChanges="orientation" />
然后将以下方法添加到此活动中:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// stuff for set video to proper position..
}
让我知道发生了什么......