diff --git a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java index d75105daf..1ad1b3e7e 100644 --- a/common/src/main/java/com/yunbao/common/utils/DialogUitl.java +++ b/common/src/main/java/com/yunbao/common/utils/DialogUitl.java @@ -78,6 +78,7 @@ public class DialogUitl { if (!TextUtils.isEmpty(content)) { TextView titleView = (TextView) dialog.findViewById(R.id.text); if (titleView != null) { + titleView.setGravity(Gravity.CENTER); titleView.setText(content); } } diff --git a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java index 6601dca54..2e5c0788f 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java @@ -5,6 +5,8 @@ import android.os.Handler; import android.os.Looper; import android.util.Log; +import androidx.annotation.NonNull; + import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.ExoPlayer; @@ -15,8 +17,6 @@ import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.StyledPlayerView; import com.google.android.exoplayer2.video.VideoSize; -import androidx.annotation.NonNull; - /** * 直播间播放器管理器 * 通过预加载子播放器来实现无缝切换分辨率功能 @@ -65,7 +65,7 @@ public class LiveExoPlayerManager { } public void setViewResizeMode(boolean isPhone) { - Log.i(TAG, "setViewResizeMode: "+isPhone); + Log.i(TAG, "setViewResizeMode: " + isPhone); mainView.setResizeMode(isPhone ? AspectRatioFrameLayout.RESIZE_MODE_ZOOM : AspectRatioFrameLayout.RESIZE_MODE_FIT); mainView.requestLayout(); } @@ -262,6 +262,7 @@ public class LiveExoPlayerManager { playBufferIndex = 0; isSwitchUrl = true; log_buffer_time = System.currentTimeMillis(); + mainView.setKeepContentOnPlayerReset(true); getNextPlayer().setMediaItem(createMediaItem(url)); getNextPlayer().prepare(); } @@ -305,6 +306,10 @@ public class LiveExoPlayerManager { getNowPlayer().play(); } + public void clearFrame() { + //mainView.setKeepContentOnPlayerReset(false); + } + /** * 释放播放器 */ 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 aac9da7cd..8b4555631 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -30,6 +30,7 @@ import com.lxj.xpopup.core.BasePopupView; import com.lxj.xpopup.interfaces.XPopupCallback; import com.lzf.easyfloat.EasyFloat; import com.lzy.okserver.OkDownload; +import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.IMLoginManager; @@ -239,6 +240,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } } + @Override + public void setLiveEnterRoomNewModel(EnterRoomNewModel data) { + super.setLiveEnterRoomNewModel(data); + mPlayer.clearFrame(); + } + /** * 暂停播放 */ @@ -390,7 +397,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { if (videoLandscape == VIDEO_VERTICAL) { height = ViewGroup.LayoutParams.MATCH_PARENT; } else { - height = DpUtil.dp2px(285); + height = ViewGroup.LayoutParams.WRAP_CONTENT; } mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); if (landscape == 2) { @@ -444,7 +451,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void setPkview() { Log.i("收到socket--->", "变成16:9"); String url = srcUrl; - if(PLAY_MODEL!=-1) { + if (PLAY_MODEL != -1) { url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv"); } mPlayer.setViewResizeMode(false); @@ -477,7 +484,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } else { String url = srcUrl; - if(PLAY_MODEL!=-1) { + if (PLAY_MODEL != -1) { url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv"); } mPlayer.setViewResizeMode(false); @@ -727,7 +734,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, - IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL), + IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR), ban, true); new XPopup.Builder(mContext) @@ -750,7 +757,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { @Override public void onDismiss(BasePopupView popupView) { int selectClarity = liveClarityCustomPopup.getSelectClarity(); - if (selectClarity == PLAY_MODEL) return; + if (selectClarity == PLAY_MODEL || selectClarity == IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR)) + return; if (selectClarity == PLAY_MODEL_ANCHOR) { switchStream(srcUrl, PLAY_MODEL_DEF); setAudiencePlayModel(selectClarity); @@ -762,7 +770,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { } private void showToast() { - DialogUitl.showToast(mContext, " 設置成功\n" + + DialogUitl.showToast(mContext, "設置成功\n" + "正在為你轉換中", 3000); }