我正在使用JWPlayer因此尝试在Orietation上保留视频和全屏幕
我的代码是:
@Override
protected void onDestroy() {
Log.i(UIH.TAG_SCR, "Is Rotated : " + isRotated);
if(!isRotated) {
playerView.stop();
} else {
isRotated = false;
}
super.onDestroy();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i(UIH.TAG_SCR, "ORIENTATION : " + newConfig.orientation);
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
isRotated = true;
Log.i(UIH.TAG_SCR, "ORIENTATION : PORTRAIT");
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
isRotated = true;
Log.i(UIH.TAG_SCR, "ORIENTATION : LANDSCAPE");
playerView.setFullscreen(true, true);
}
super.onConfigurationChanged(newConfig);
}
但它不起作用!
LogCat是:
I / SCREEN_TAG:ORIENTATION:1
I / SCREEN_TAG:ORIENTATION:PORTRAIT
I / SCREEN_TAG:已旋转:为真
I / SCREEN_TAG:ORIENTATION:2
I / SCREEN_TAG:ORIENTATION:LANDSCAPE
I / SCREEN_TAG:已旋转:为真
答案 0 :(得分:2)
试试这个:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
if(playerView.getFullscreen()) {
playerView.setFullscreen(false, true);
}
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if(!playerView.getFullscreen()) {
playerView.setFullscreen(true, true);
}
}
}
对我有用。