修复多人连麦下麦后播放器横竖屏切换异常

This commit is contained in:
zlzw 2022-11-30 13:15:40 +08:00
parent f5bd17f832
commit f257c2b5a9

View File

@ -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;
@ -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--->", "还原916");
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.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();