我在这样的 Android 设备上以 PORTRAIT 方向拍摄新视频:
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 中旋转此视频?
另外,我如何以编程方式确定方向?