From f257c2b5a9c23dd603784a84db173deebd358dfa Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 30 Nov 2022 13:15:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E4=BA=BA=E8=BF=9E?= =?UTF-8?q?=E9=BA=A6=E4=B8=8B=E9=BA=A6=E5=90=8E=E6=92=AD=E6=94=BE=E5=99=A8?= =?UTF-8?q?=E6=A8=AA=E7=AB=96=E5=B1=8F=E5=88=87=E6=8D=A2=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../live/views/LivePlayRyViewHolder.java | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 7bb2a6f38..56b7cbbc5 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -28,7 +28,6 @@ import com.tencent.live2.V2TXLivePlayer; import com.tencent.live2.V2TXLivePlayerObserver; import com.tencent.live2.impl.V2TXLivePlayerImpl; import com.tencent.rtmp.ui.TXCloudVideoView; -import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.utils.DialogUitl; @@ -80,7 +79,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { private RelativeLayout mPkContainer; public static TXCloudVideoView mVideoView; - private View mLoading,mLoading2; + private View mLoading, mLoading2; private ImageView mCover; private boolean mPaused;//是否切后台了 private boolean mStarted;//是否开始了播放 @@ -93,9 +92,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public V2TXLivePlayer mPlayer; public static FrameLayout ry_view; - - int screenWidth; // 屏幕宽(像素,如:480px) - int screenHeight; // 屏幕高(像素,如:800p) + private static final int VIDEO_VERTICAL=1; + private static final int VIDEO_HORIZONTAL=2; + int videoLandscape; // 视频方向,1=竖屏,2=横屏 static int vHeight;//视频高 @@ -325,6 +324,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } hideCover(); Log.i(TAG, "onStatisticsUpdate: " + JSON.toJSONString(statistics) + " |当前下载数 : " + OkDownload.getInstance().getTaskMap().size() + buffer); + if (statistics.height > statistics.width) { + videoLandscape = VIDEO_VERTICAL; + } else { + videoLandscape = VIDEO_HORIZONTAL; + } if (statistics.fps == 0) { OkDownload.getInstance().pauseAll(); } else { @@ -408,36 +412,55 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { release(); return; } + int height; + if(videoLandscape==VIDEO_VERTICAL){ + height= ViewGroup.LayoutParams.MATCH_PARENT; + }else{ + height=DpUtil.dp2px(285); + } if (landscape == 2) { Log.i("收到socket--->", "还原9:16"); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); - params.height = RelativeLayout.LayoutParams.MATCH_PARENT; + params.height = height; params.topMargin = 0; + params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + params.addRule(RelativeLayout.ALIGN_TOP); + mVideoView.setLayoutParams(params); mVideoView.requestLayout(); RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); - params1.height = RelativeLayout.LayoutParams.MATCH_PARENT; + params1.height = height; params1.topMargin = 0; + params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + ry_view.setLayoutParams(params1); ry_view.requestLayout(); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); - params2.height = RelativeLayout.LayoutParams.MATCH_PARENT; + params2.height = height; params2.topMargin = 0; mCover.setLayoutParams(params2); mCover.requestLayout(); } else { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); - params.height = vHeight; - params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + params.height = height; + params.topMargin = 0; + if(videoLandscape==VIDEO_HORIZONTAL){ + params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + } params.addRule(RelativeLayout.ALIGN_TOP); + mVideoView.setLayoutParams(params); mVideoView.requestLayout(); RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams(); - params1.height = vHeight; - params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + params1.height = height; + params1.topMargin = 0; params1.addRule(RelativeLayout.ALIGN_TOP); + if(videoLandscape==VIDEO_HORIZONTAL){ + params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); + } + ry_view.setLayoutParams(params1); ry_view.requestLayout(); RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams(); - params2.height = DpUtil.dp2px(270); + params2.height =height; params2.topMargin = DpUtil.dp2px(120); mCover.setLayoutParams(params2); mCover.requestLayout();