次のように、Android デバイスで縦向きの新しいビデオをキャプチャします。
Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, 1886);
そして、このファイルが表示されます:「/mnt/sdcard/DCIM/Camera/video-2012-02-02-10-45-48.mp4」
次に、次のように再生します。
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();
これが私のレイアウトファイルです:
<?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>
標準の Android ギャラリーで再生すると、向きが正しく表示されます。しかし、上記の VideoView でビデオを再生すると、90 度回転します。横向きはうまく機能しますが、唯一の問題は縦向きのビデオです。
VideoView でこのビデオを回転するにはどうすればよいですか?
また、プログラムで向きを決定するにはどうすればよいですか?