I want to show my Video with normal size on portrait, and with Full Size on Landscape. So when the users starts to watch at portrait and switches to Landscape(Rotates the device) It goes fullscreen; when vice versa, It goes back to original size. I've checked internet but couldn't find a good example. My codes are below.
VideoActivity.java:
public class VideoActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_video);
Bundle bund = getIntent().getExtras();
String s = bund.getString("LINK");
VideoView videoView = (VideoView) findViewById(R.id.videoView);
MediaController controller = new MediaController(this);
videoView.setVideoPath(s);
videoView.setMediaController(controller);
videoView.start();
}
}
activity_video.xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}"
android:background="#000000"
>
<VideoView
android:id="@+id/videoView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
/>
</RelativeLayout>
Basically. When user starts the video it can be original size (If Portrait Mode) but whenever he turns the phone around I want it to go fullscreen automatically. And when turned back to portrait, original size again.
Thanks.