如何保持播放视频的同时切换到横向模式的android [英] How to keep playing video while changing to landscape mode android

查看:254
本文介绍了如何保持播放视频的同时切换到横向模式的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在播放视频(在 VideoView )的肖像模式(不是全屏幕),当我切换到

I'm playing video (on VideoView) on portrait mode (not on full screen) and when I change to

横向模式的视频站。

当我将其更改为景观的视频将出现在全屏幕上,并会继续打球。

When I change it to landscape that video will appear on full screen and will keep playing.

任何建议?

推荐答案

所有你需要做的是添加到活动中的Andr​​oidManifest.xml:

all you need to do is add this to activity in AndroidManifest.xml:

 android:configChanges="orientation"

您的视频活动应该是这个样子。

Your Video activity should look something like this.

 <activity android:name=".VideoPlayerActivity" 
  android:configChanges="orientation" />

如果你的目标API级别13或更高,则必须包含除定位屏幕尺寸价值如<一个href="http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange">here.您的视频活动应该是这个样子。

If your target API level 13 or higher, you must include the screenSize value in addition to the orientation value as described here. Your Video activity should look something like this.

 <activity android:name=".VideoPlayerActivity" 
  android:configChanges="orientation|screenSize" />

,然后添加下面的方法VideoPlayerActivity:

And then add the following method to VideoPlayerActivity:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}

这篇关于如何保持播放视频的同时切换到横向模式的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆