J J*_*J J 5 video android orientation media-player android-videoview
我正在写一个活动,它将在我的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>
Run Code Online (Sandbox Code Playgroud)
视频代码:
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();
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
小智 0
为了完整起见,我将回答这个问题。这句话之前已经发过好几次了。转到您的 Android Manifest 并将其添加到您想要锁定方向的活动声明中
android:screenOrientation="portrait"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2965 次 |
| 最近记录: |