【发布时间】:2011-06-16 20:10:35
【问题描述】:
我正在编写一个将在我的 SD 卡上播放视频文件的活动。我有这个代码工作。
视频的方向取决于我的手机是垂直还是水平。我想强制我的视频水平播放(如默认播放器)。有没有办法做到这一点?
我的代码:
布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="horizontal">
<VideoView android:id="@+id/VideoView"
android:layout_width="fill_parent" android:layout_height="fill_parent">
</VideoView>
</LinearLayout>
视频代码:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.video_view);
mVideoView = (VideoView)this.findViewById(R.id.VideoView);
String videoUrl = "/mnt/sdcard-ext" + "/Videos/Wildlife.wmv";
MediaController mc = new MediaController(this);
mc.setAnchorView(mVideoView);
mVideoView.setMediaController(mc);
mVideoView.setVideoURI(Uri.parse(videoUrl));
mVideoView.requestFocus();
mVideoView.start();
}
有什么想法吗?
【问题讨论】:
-
我只是想尝试锁定方向...我会尝试并回复。
-
是的,这似乎成功了。
-
能否请您发布答案。
标签: android video orientation media-player android-videoview