In android manifest set this attribute to yor video activity.
android:configChanges="orientation|keyboardHidden"
문제
Recently I designed a multimedia player. But when I try to switch between landscape and portrait modes, the video restarts.
Is there any guide or tutorial for this issue?
I want video to play well in both landscape and portrait view.
This is my sample code in MainActivity.java
VideoView videoView =(VideoView)findViewById(R.id.videoView1);
//Creating MediaController
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
//specify the location of media file
Uri uri=Uri.parse(Environment.getExternalStorageDirectory() + "/video.mp4");
//Setting MediaController and URI, then starting the videoView
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
}
해결책
In android manifest set this attribute to yor video activity.
android:configChanges="orientation|keyboardHidden"