Reputation: 6912
vv = (VideoView)this.findViewById(R.id.videoView1);
Uri uri = Uri.parse(url);
vv.setVideoURI(uri);
vv.start();
I use VideoView to play an url video. like above. But while I change th phone screenOrientation. It will reload all video. How to improve the program to the reloading action? Thanks a lot.
Upvotes: 0
Views: 1108
Reputation: 109237
Solution 1: (In most case this works..)
Modifies your VideoView xml file something like,
<?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>
Solution 2..
Or Handle orientation change in your activity,
For activity tag of video in AndroidManifest.xml:
android:configChanges="orientation"
So the whole line would look like this:
<activity android:name="<Your video avtivityy>" android:configChanges="orientation" />
And then add the following method to this activity:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// stuff for set video to proper position..
}
And let me know what happen...
Upvotes: 2