I'm trying to play the video using the videoview for landscape mode, but it is not taking the full screen for landscape mode.
I've tried to set the params in the Activity class too but it is still not working. I've set the orientation landscape in the manifest:
public class WatchNowComedyDataScreen extends AppCompatActivity {
VideoView videoViews;
ProgressBar progressbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_watch_now_comedy_data_screen);
progressbar = findViewById(R.id.progress_bar1);
videoViews = findViewById(R.id.watchVideo);
progressbar.setVisibility(View.VISIBLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().invalidate();
float height = getWidthInPx(this);
float width = getHeightInPx(this);
videoViews.getLayoutParams().height = (int) width;
videoViews.getLayoutParams().width = (int) height;
videoViews.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
mp.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int arg1, int arg2) {
progressbar.setVisibility(View.GONE);
mp.start();
}
});
}
});
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoViews);
Uri uri = Uri.parse("https://oakstudio-usso.streaming.media.azure.net/e989b22b-cef5-497d-af3f-4c8e4c85b50f/Avatar-Trailer_848x480_2200.mp4");
videoViews.setMediaController(mediaController);
videoViews.setVideoURI(uri);
videoViews.requestFocus();
videoViews.start();
}
}