视频流相关横屏修改

This commit is contained in:
ningwenqiang 2024-08-22 13:52:00 +08:00
parent 6e7d27cbc3
commit 1df8d443f7
9 changed files with 208 additions and 86 deletions

View File

@ -43,6 +43,11 @@ public abstract class AbsViewHolder implements LifeCycleListener {
}
public void onConfigureChange() {
//如果 mParentView
}
protected abstract int getLayoutId();
public abstract void init();

View File

@ -24,6 +24,6 @@ android.nonTransitiveRClass=false
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890
systemProp.http.proxyPort=7890
systemProp.https.proxyPort=9098
systemProp.http.proxyPort=9098
#android.enableR8.fullMode=true

View File

@ -188,7 +188,7 @@ public class SWAuManager extends BaseCacheManager {
// 创建一个 TextureView 对象并将其作为 FrameLayout 的子对象
TextureView surfaceView = new TextureView(mContext);
audienceContainer.addView(surfaceView);
Log.i("nwq"," audienceContainer.getChildCount()"+ audienceContainer.getChildCount());
// 启用视频模块
mRtcEngine.enableVideo();

View File

@ -291,9 +291,6 @@ public class LiveAudienceActivity extends LiveActivity {
};
/**
* 初始化界面
*/
@ -911,11 +908,21 @@ public class LiveAudienceActivity extends LiveActivity {
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.i(TAG,"onConfigurationChanged");
Log.i(TAG, "onConfigurationChanged");
adjustFullScreen(newConfig);
liveHandler.post(liveRunnable);
onConfigurationChangedView(newConfig);
}
public void onConfigurationChangedView( Configuration newConfig) {
if (manager != null && manager.getRootView() != null && mLiveBean != null && mViewGroup != null) {
manager.onConfigurationChanged(newConfig);
manager.onAdd(mLiveBean, mLiveType, mLiveTypeVal, mLiveSDK, isSw);
}
}
private void adjustFullScreen(Configuration config) {
final WindowInsetsControllerCompat insetsController = ViewCompat.getWindowInsetsController(getWindow().getDecorView());
if (insetsController == null) return;
@ -1897,9 +1904,9 @@ public class LiveAudienceActivity extends LiveActivity {
if (manager == null || manager.mLiveAudienceViewHolder == null || manager.mLiveAudienceViewHolder.mRedPoint == null) {
return;
}
if(event.getNumber()>0){
if (event.getNumber() > 0) {
manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.VISIBLE);
}else{
} else {
manager.mLiveAudienceViewHolder.mRedPoint.setVisibility(View.GONE);
}

View File

@ -5,6 +5,7 @@ import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.media.AudioManager;
import android.os.Build;
@ -135,6 +136,10 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
return landscape;
}
private boolean isPhysicalScreenVertical() {
return contexts.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
}
public LivePlaySwViewHolder(Context context, ViewGroup parentView, int landscapes) {
super(context, parentView);
contexts = context;
@ -183,6 +188,54 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
dr_pk_view.setVisibility(View.GONE);
}
public void onConfigureChange() {
if (contexts == null) {
return;
}
//如果mContentView有父类则移除
if (mContentView != null && mContentView.getParent() != null) {
((ViewGroup) mContentView.getParent()).removeView(mContentView);
}
//这里考虑只通过修改参数的方式实现
if (isPhysicalScreenVertical()) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams();
params.height = DpUtil.dp2px(280);
params.topMargin = DpUtil.dp2px(130);
mPkContainer.setLayoutParams(params);
if (mPkContainer.getVisibility() == View.VISIBLE) {
mPkContainer.requestLayout();
}
params = (RelativeLayout.LayoutParams) dr_pk_view.getLayoutParams();
params.height = DpUtil.dp2px(280);
params.topMargin = DpUtil.dp2px(130);
dr_pk_view.setLayoutParams(params);
if (dr_pk_view.getVisibility() == View.VISIBLE) {
dr_pk_view.requestLayout();
}
} else {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams();
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
mPkContainer.setLayoutParams(params);
if (mPkContainer.getVisibility() == View.VISIBLE) {
mPkContainer.requestLayout();
}
params = (RelativeLayout.LayoutParams) dr_pk_view.getLayoutParams();
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
dr_pk_view.setLayoutParams(params);
if (dr_pk_view.getVisibility() == View.VISIBLE) {
dr_pk_view.requestLayout();
}
}
}
public void initSwEngine(String liveUid) {
dr_pk_view.setVisibility(View.GONE);
this.liveUid = liveUid;
@ -224,7 +277,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
@Override
public void onSuccess(io.rong.imlib.model.Message message) {
Log.e("ry", "发送成功");
IMCenter.getInstance().deleteRemoteMessages(Conversation.ConversationType.PRIVATE, message.getTargetId(), new Message[]{message}, null);
IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, message.getTargetId(), null);
MicedUserManager.get().removeMiscUser(CommonAppConfig.getInstance().getUid());
@ -464,8 +516,49 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
Log.i(TAG, "setLiveBeanLandscape: " + landscape + " isPk: " + isPk);
this.landscape = landscape;
this.videoLandscape = landscape;
if (landscape == 2) {
Log.i(TAG, "还原916");
if (isPhysicalScreenVertical()) {
if (landscape == 2) {
Log.i(TAG, "还原916");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
ry_view.setLayoutParams(params);
ry_view.requestLayout();
/* RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params1.topMargin = 0;
ry_view.setLayoutParams(params1);
ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params2.topMargin = 0;
mCover.setLayoutParams(params2);
mCover.requestLayout();
} else {
Log.i(TAG, "还原16:9");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params);
ry_view.requestLayout();
/*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight;
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1);
ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120);
mCover.setLayoutParams(params2);
mCover.requestLayout();
}
} else {
Log.i(TAG, "还原横屏 169");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
@ -482,27 +575,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
params2.topMargin = 0;
mCover.setLayoutParams(params2);
mCover.requestLayout();
} else {
Log.i(TAG, "还原16:9");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params);
ry_view.requestLayout();
/*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight;
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1);
ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120);
mCover.setLayoutParams(params2);
mCover.requestLayout();
}
}
@ -618,7 +690,7 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.setLayoutParams(params1);
ry_view.requestLayout();*/
ry_view.requestLayout(); */
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = DpUtil.dp2px(270);
params2.topMargin = DpUtil.dp2px(120);
@ -664,11 +736,12 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
Log.e("PK状态", "" + i);
/*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
/*
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = vHeight;
params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.requestLayout();*/
ry_view.requestLayout(); */
isPk = true;
}
@ -682,41 +755,42 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
return;
}
int height;
if (videoLandscape == VIDEO_VERTICAL) {
height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
height = ViewGroup.LayoutParams.WRAP_CONTENT;
}
if (landscape == 2) {
Log.i(TAG, "onPrepared:还原916 land=" + videoLandscape);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = height;
params.topMargin = 0;
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
if (isPhysicalScreenVertical()) {
if (videoLandscape == VIDEO_VERTICAL) {
height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
height = ViewGroup.LayoutParams.WRAP_CONTENT;
}
if (landscape == 2) {
Log.i(TAG, "onPrepared:还原916 land=" + videoLandscape);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = height;
params.topMargin = 0;
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
/*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
params1.height = height;
params1.topMargin = 0;
ry_view.setLayoutParams(params1);
ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height;
params2.topMargin = 0;
mCover.setLayoutParams(params2);
mCover.requestLayout();
} else {
Log.i(TAG, "onPrepared:还原169");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
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 params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height;
params2.topMargin = 0;
mCover.setLayoutParams(params2);
mCover.requestLayout();
} else {
Log.i(TAG, "onPrepared:还原169");
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
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 = height;
@ -727,9 +801,24 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
}
ry_view.setLayoutParams(params1);
ry_view.requestLayout();*/
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height;
params2.topMargin = DpUtil.dp2px(120);
mCover.setLayoutParams(params2);
mCover.requestLayout();
}
} else {
Log.i(TAG, " onPrepared:还原横屏169 land=" + videoLandscape);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
params.topMargin = 0;
params.addRule(RelativeLayout.ALIGN_TOP);
mVideoView.setLayoutParams(params);
mVideoView.requestLayout();
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
params2.height = height;
params2.topMargin = DpUtil.dp2px(120);
params2.height = ViewGroup.LayoutParams.MATCH_PARENT;
params2.topMargin = 0;
mCover.setLayoutParams(params2);
mCover.requestLayout();
}
@ -802,7 +891,6 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
@Override
public void changeToLeft() {
if (mVideoView != null) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);

View File

@ -5,6 +5,7 @@ import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Outline;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@ -1000,8 +1001,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
}).into(dr_pk_end_gif);
}
}
private boolean isPorit(){
return true;
}
public static void UpPkBar(JSONArray obj, String uid, int time) {
@ -1175,6 +1178,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
private boolean isPortrait(Context context){
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
}
@Override
public void init() {
@ -1412,17 +1419,27 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
gif_view = (LinearLayout) findViewById(R.id.gif_view);
chat_view = (RelativeLayout) findViewById(R.id.chat_view);
int topMargin = mScreenWdith * 720 / 960 + 210;
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_view.getLayoutParams();
params.topMargin = topMargin;
chat_view.setLayoutParams(params);
if(isPortrait(mContentView.getContext())){
int topMargin = mScreenWdith * 720 / 960 + 210;
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_view.getLayoutParams();
params.topMargin = topMargin;
chat_view.setLayoutParams(params);
RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams();
msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50);
msgLayout.setLayoutParams(msgLayoutLayoutParams);
voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50));
}else {
int topMargin = mScreenWdith * 190 / 960 ;
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_view.getLayoutParams();
params.topMargin = topMargin;
chat_view.setLayoutParams(params);
RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams();
msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50);
msgLayout.setLayoutParams(msgLayoutLayoutParams);
voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50));
}
RelativeLayout.LayoutParams msgLayoutLayoutParams = (RelativeLayout.LayoutParams) msgLayout.getLayoutParams();
msgLayoutLayoutParams.topMargin = topMargin + DpUtil.dp2px(50);
msgLayout.setLayoutParams(msgLayoutLayoutParams);
voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50));
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) mChatRecyclerView.getLayoutParams();
params1.topMargin = DpUtil.dp2px(65);
mChatRecyclerView.setLayoutParams(params1);

View File

@ -520,6 +520,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
};
//屏幕方向改变
public void onConfigureChange() {
}
/**
* 新进入房间接口
*/
@ -1125,7 +1130,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onConfigurationChanged(Configuration newConfig) {
mLivePlayViewHolder.onConfigureChange();
}
@Override

View File

@ -18,7 +18,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:orientation="horizontal">
@ -31,7 +31,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
@ -47,8 +46,7 @@
<FrameLayout
android:id="@+id/pk_container"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_marginTop="130dp">
android:layout_height="match_parent">
<com.yunbao.live.custom.MyFrameLayout4
android:id="@+id/left_container"
@ -64,12 +62,13 @@
android:layout_marginBottom="20dp" />
</FrameLayout>
<LinearLayout
android:id="@+id/dr_pk_view"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_marginTop="130dp"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:visibility="visible"
android:visibility="gone">
<LinearLayout

View File

@ -194,6 +194,7 @@
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_marginTop="170dp"
android:layout_marginEnd="380dp"
android:overScrollMode="never"
android:scrollbars="none" />