如何在更改为横向模式时继续播放视频android [英] How to keep playing video while changing to landscape mode 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.
有什么建议吗?
推荐答案
您需要做的就是将其添加到 AndroidManifest.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 或更高,则除了 orientation
值之外,您还必须包括 screenSize
值,如此处.您的视频活动应如下所示.
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屋!