I capture a new video in PORTRAIT orientation on an Android device like this:
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, 1886);
and it gives me this file: "/mnt/sdcard/DCIM/Camera/video-2012-02-02-10-45-48.mp4"
Then I play it like this:
private VideoView videoView = (VideoView) findViewById(R.id.videoView);
String videoUrl = "/mnt/sdcard/DCIM/Camera/video-2012-02-02-10-45-48.mp4";
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(Uri.parse(videoUrl));
videoView.start();
Here's my layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true" />
</RelativeLayout>
When I play it in the standard Android gallery, the orientation is correct. But when I play the video in the VideoView above, it's rotated 90 degrees. Landscape works great, the only problem are portrait videos.
How can I rotate this video in the VideoView?
Also, how can I programmatically determine the orientation?