diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index d0a31a528..60e3303fc 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -409,6 +409,9 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { handler.postDelayed(runnable = new Runnable() { @Override public void run() { + if(!liveUid.equals(mLiveUid)){ + return; + } if (isattention == 0) { LiveChatBean lvBean = new LiveChatBean(); lvBean.setType(-1); @@ -418,6 +421,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { LiveChatBean lvBean2 = new LiveChatBean(); lvBean2.setType(-2); LiveRoomViewHolder.insertChat(lvBean2, 1); + Log.i("chatMgs", liveUid+"|"+mLiveUid); } }, 10000);//3秒后执行Runnable中的run方法 } 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 59a3cb96c..3528bc106 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -146,7 +146,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams(); params.height = vHeight; mPkContainer.requestLayout(); - + mPlayer = new V2TXLivePlayerImpl(mContext); + mPlayer.setRenderView(mVideoView); } @Override @@ -192,12 +193,12 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { return; } - mPlayer = new V2TXLivePlayerImpl(mContext); if (TextUtils.isEmpty(url) || mVideoView == null) { return; } //mPlayer.setCacheParams(1.0f, 5.0f); + mVideoView.clearLastFrame(true); mPlayer.setObserver(new V2TXLivePlayerObserver() { String TAG = "播放流"; @@ -292,7 +293,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { super.onReceiveSeiMessage(player, payloadType, data); } }); - mPlayer.setRenderView(mVideoView); + purl = url; mPlayer.startPlay(url); onPrepared(); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 815b1caa3..320707f6a 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1056,7 +1056,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis }); } - + public void clearChat(){ + if(mLiveChatAdapter!=null){ + mLiveChatAdapter.clear(); + } + } + public void clearGuardIcon(){ + if(userGuard!=null){ + userGuard.setImageResource(R.mipmap.img_guardian_empty); + } + } public synchronized void showStart(StarChallengeStatusModel data) { boolean upData = false; if (mBannerList2 != null && mBannerList2.size() == 0) { diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index c46312132..339e3c83b 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -11,6 +11,7 @@ import android.content.Intent; import android.content.res.Configuration; import android.os.CountDownTimer; import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -244,31 +245,34 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe .setParametersModel(openParametersModel .setmLiveType(mLiveType) .setmLiveTypeVal(mLiveTypeVal))); - mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mLiveBean.getLandscape()); - mLivePlayViewHolder.addToParent(); - mLivePlayViewHolder.subscribeActivityLifeCycle(); - mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); - mLiveRoomViewHolder.subscribeActivityLifeCycle(); - mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); - mLiveAudienceViewHolder.addToParent(); - mLiveRoomViewHolder.addToParent(); - mLiveAudienceViewHolder.subscribeActivityLifeCycle(); - mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); - mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null); - - mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); + if (mLivePlayViewHolder == null) { + mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mLiveBean.getLandscape()); + mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); + mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); + mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); + mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null); + mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); + mLivePlayViewHolder.addToParent(); + mLivePlayViewHolder.subscribeActivityLifeCycle(); + mLiveRoomViewHolder.subscribeActivityLifeCycle(); + mLiveAudienceViewHolder.addToParent(); + mLiveRoomViewHolder.addToParent(); + mLiveAudienceViewHolder.subscribeActivityLifeCycle(); + } //直播间背景 ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600); //ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack); mask.setVisibility(View.VISIBLE); mLivePlayViewHolder.setCover(data.getThumb()); mLivePlayViewHolder.play(data.getPull()); + mLiveRoomViewHolder.clearChat(); mLiveRoomViewHolder.setAvatar(data.getAvatar()); mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); mLiveRoomViewHolder.setName(data.getUserNiceName()); mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); mLiveRoomViewHolder.setTitle(data.getTitle()); mLiveRoomViewHolder.setAnchorGoodNumber(data.getGoodNum()); + mLiveRoomViewHolder.clearGuardIcon(); mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); @@ -321,43 +325,20 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe IMLoginManager.get(mContext).setisNewUserOne(false); //子线程执行退出操作 exitLiveRoom(false); - if (mLiveAudienceViewHolder != null) { - mLiveAudienceViewHolder.removeFromParent(); - mLiveAudienceViewHolder.removeCallbacks(); - mLiveAudienceViewHolder.release(); - } - mLiveAudienceViewHolder = null; + + //断开socket if (mSocketRyClient != null) { mSocketRyClient.disConnect(); + mSocketRyClient = null; } - mSocketRyClient = null; - //结束播放 - if (mLivePlayViewHolder != null) { - mLivePlayViewHolder.removeFromParent(); - mLivePlayViewHolder.stopPlay(); - mLivePlayViewHolder.release(); - } - mLivePlayViewHolder = null; if (mSocketClient != null) { - mSocketClient.disConnect(); mSocketClient = null; } - if (mLiveRoomViewHolder != null) { - mLiveRoomViewHolder.removeFromParent(); - mLiveRoomViewHolder.clearData(); - mLiveRoomViewHolder.countDownTimerTrickery = null; - mLiveRoomViewHolder = null; - } - if (mLiveEndViewHolder != null) { - mLiveEndViewHolder.removeFromParent(); - mLiveEndViewHolder.release(); - mLiveEndViewHolder = null; - } if (mLiveLinkMicPresenter != null) { mLiveLinkMicPresenter.clearData(); mLiveLinkMicPresenter.release(); @@ -372,6 +353,33 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } if (isQuit) { isQuitF = true; + if (mLiveAudienceViewHolder != null) { + mLiveAudienceViewHolder.removeFromParent(); + mLiveAudienceViewHolder.removeCallbacks(); + mLiveAudienceViewHolder.release(); + } + //结束播放 + if (mLivePlayViewHolder != null) { + mLivePlayViewHolder.removeFromParent(); + mLivePlayViewHolder.stopPlay(); + mLivePlayViewHolder.release(); + } + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.removeFromParent(); + mLiveRoomViewHolder.clearData(); + mLiveRoomViewHolder.countDownTimerTrickery = null; + } + if (mLiveEndViewHolder != null) { + mLiveEndViewHolder.removeFromParent(); + mLiveEndViewHolder.release(); + } + mLiveAudienceViewHolder = null; + mLivePlayViewHolder = null; + mLiveRoomViewHolder = null; + mLiveEndViewHolder = null; + mLiveLinkMicPresenter=null; + mLiveLinkMicAnchorPresenter=null; + mLiveRyLinkMicPkPresenter=null; if (PermissionUtils.checkPermission(mContext) && !kick) { LiveFloatView.getInstance() .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal)