小编Tod*_*son的帖子

VideoView中Android纵向视频方向错误

我在Android设备上以PORTRAIT方向捕获了一个新视频,如下所示:

Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); 
startActivityForResult(intent, 1886);
Run Code Online (Sandbox Code Playgroud)

它给了我这个文件:"/ 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();
Run Code Online (Sandbox Code Playgroud)

这是我的布局文件:

<?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>
Run Code Online (Sandbox Code Playgroud)

当我在标准Android画廊中播放时,方向是正确的.但是当我在上面的VideoView中播放视频时,它旋转了90度.景观效果很好,唯一的问题是人像视频.

如何在VideoView中旋转此视频?
另外,我如何以编程方式确定方向?

video android portrait orientation android-videoview

10
推荐指数
1
解决办法
2595
查看次数