I want to show my captured video in another activity but the problem is when I play that video, It shows in landscape mode even I want to show portrait only.
At screenshot you can see the captured video plays in landscape but it should play in portrait mode.
Captured Screen :
public class AndroidVideoViewExample extends Activity {
private VideoView myVideoView;
private int position = 0;
private ProgressDialog progressDialog;
private MediaController mediaControls;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the layout from video_main.xml
setContentView(R.layout.videodemo);
if (mediaControls == null) {
mediaControls = new MediaController(AndroidVideoViewExample.this);
}
// Find your VideoView in your video_main.xml layout
myVideoView = (VideoView) findViewById(R.id.video_view);
// Create a progressbar
progressDialog = new ProgressDialog(AndroidVideoViewExample.this);
// Set progressbar title
progressDialog.setTitle("JavaCodeGeeks Android Video View Example");
// Set progressbar message
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
// Show progressbar
progressDialog.show();
try {
myVideoView.setMediaController(mediaControls);
myVideoView.setVideoURI(Uri.parse(android.os.Environment.getExternalStorageDirectory()+AppConstants.GAME_IMAGE_DIR+"/myvideo1.mp4"));
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
myVideoView.requestFocus();
myVideoView.setOnPreparedListener(new OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
myVideoView.seekTo(position);
if (position == 0) {
myVideoView.start();
} else {
myVideoView.pause();
}
}
});
}
}
And Xml file is :
<FrameLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/video_view"
android:layout_width="720px"
android:layout_height="720px"
android:layout_gravity="center|center_vertical" />
</FrameLayout>
No comments:
Post a Comment