I am creating a video streaming application , I want when I switch to landscape it goes to full screen but it should not load the video from the start again. I want to to switch smoothly without affecting the current playing.Help.
public class MainActivity extends Activity {
VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView) findViewById(R.id.vid);
String vidAddress = "http://campusvibe.co.nf/blender.mp4";
Uri vidUri = Uri.parse(vidAddress);
MediaController vidControl = new MediaController(this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.setVideoURI(vidUri);
videoView.start();
}
}
This is for the portrait mode
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3090C7">
<VideoView
android:id="@+id/vid"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_gravity="center">
</VideoView>
</RelativeLayout>
This is for the landscape mode
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3090C7">
<VideoView
android:id="@+id/vid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"></VideoView>
</RelativeLayout>