0

I am a beginner in android studio and I need your help so I create a video player appliction but I have a problem with the orientation of the smartphone if you can help me to resize the demensions of the videoview in both cases (LANDSCAPE or PORTRAIT) it is necessary to remain the video in full screen and thank you very much

my code

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        Toast.makeText(getBaseContext(),"wa9fa",Toast.LENGTH_SHORT).show();
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
   else if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
        Toast.makeText(getBaseContext(),"na3sa",Toast.LENGTH_SHORT).show();
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }


    VideoView videoView = (VideoView)findViewById(R.id.videoView);
 String path = "android.resource://" + getPackageName() + "/" + R.raw.track01;
    videoView.setVideoURI(Uri.parse(path));

    MediaController mediaController = new MediaController(this);
    mediaController.setMediaPlayer(videoView);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);

    videoView.start();
}
mani hani
  • 1
  • 3
  • Hello and welcome :) Please post your code showing the problem. – Zippy May 16 '18 at 23:44
  • It might help you to create a custom VideoView, check out this question/answer to see if it helps you... https://stackoverflow.com/questions/4434027/android-videoview-orientation-change-with-buffered-video – Zippy May 17 '18 at 13:31

0 Answers0