直播横竖屏问题修改

This commit is contained in:
18401019693 2022-12-01 19:04:46 +08:00
parent 455b330b7d
commit efcc2591c2

View File

@ -33,7 +33,6 @@ import com.tencent.live2.V2TXLivePlayer;
import com.tencent.live2.V2TXLivePlayerObserver; import com.tencent.live2.V2TXLivePlayerObserver;
import com.tencent.live2.impl.V2TXLivePlayerImpl; import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView; import com.tencent.rtmp.ui.TXCloudVideoView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DeviceUtils;
@ -196,13 +195,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (landscape == 2) { if (landscape == 2) {
Log.i("收到socket--->", "还原916"); Log.i("收到socket--->", "还原916");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = DeviceUtils.getScreenHeight((Activity) mContext); params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0; params.topMargin = 0;
mVideoView.setLayoutParams(params); mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); mVideoView.requestLayout();
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = DeviceUtils.getScreenHeight((Activity) mContext); params1.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params1.topMargin = 0; params1.topMargin = 0;
ry_view.setLayoutParams(params1); ry_view.setLayoutParams(params1);
ry_view.requestLayout(); ry_view.requestLayout();
@ -455,53 +454,53 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} else { } else {
height = DpUtil.dp2px(285); height = DpUtil.dp2px(285);
} }
if (landscape == 2) { // if (landscape == 2) {
Log.i("收到socket--->", "还原916"); // Log.i("收到socket--->", "还原916");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); // RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = height; // params.height = height;
params.topMargin = 0; // params.topMargin = 0;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); // params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP); // params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.setLayoutParams(params); // mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); // mVideoView.requestLayout();
//
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); // RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = height; // params1.height = height;
params1.topMargin = 0; // params1.topMargin = 0;
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); // params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
ry_view.setLayoutParams(params1); // ry_view.setLayoutParams(params1);
ry_view.requestLayout(); // ry_view.requestLayout();
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); // RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height; // params2.height = height;
params2.topMargin = 0; // params2.topMargin = 0;
mCover.setLayoutParams(params2); // mCover.setLayoutParams(params2);
mCover.requestLayout(); // mCover.requestLayout();
} else { // } else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); // RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = height; // params.height = height;
params.topMargin = 0; // params.topMargin = 0;
if (videoLandscape == VIDEO_HORIZONTAL) { // if (videoLandscape == VIDEO_HORIZONTAL) {
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); // params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
} // }
params.addRule(RelativeLayout.ALIGN_TOP); // params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.setLayoutParams(params); // mVideoView.setLayoutParams(params);
mVideoView.requestLayout(); // mVideoView.requestLayout();
//
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); // RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = height; // params1.height = height;
params1.topMargin = 0; // params1.topMargin = 0;
params1.addRule(RelativeLayout.ALIGN_TOP); // params1.addRule(RelativeLayout.ALIGN_TOP);
if (videoLandscape == VIDEO_HORIZONTAL) { // if (videoLandscape == VIDEO_HORIZONTAL) {
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); // params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
} // }
ry_view.setLayoutParams(params1); // ry_view.setLayoutParams(params1);
ry_view.requestLayout(); // ry_view.requestLayout();
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); // RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height; // params2.height = height;
params2.topMargin = DpUtil.dp2px(120); // params2.topMargin = DpUtil.dp2px(120);
mCover.setLayoutParams(params2); // mCover.setLayoutParams(params2);
mCover.requestLayout(); // mCover.requestLayout();
} // }
} }
@Override @Override
@ -519,20 +518,20 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Log.i("收收收", landscape + ""); Log.i("收收收", landscape + "");
if (landscape == 2) { // if (landscape == 2) {
Log.i("收到socket--->", "还原916"); // Log.i("收到socket--->", "还原916");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); // RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT; // params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0; // params.topMargin = 0;
mVideoView.requestLayout(); // mVideoView.requestLayout();
//
} else { // } else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); // RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight; // params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); // params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP); // params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.requestLayout(); // mVideoView.requestLayout();
} // }
} }