|
@@ -19,6 +19,7 @@ import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.view.WindowManager;
|
|
|
+import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.RelativeLayout;
|
|
@@ -51,6 +52,8 @@ import com.cooleshow.student.bean.LiveRoomInfoBean;
|
|
|
import com.cooleshow.student.contract.LiveRoomContract;
|
|
|
import com.cooleshow.student.databinding.ActivityLiveroomLayoutBinding;
|
|
|
import com.cooleshow.student.presenter.live.LiveRoomPresenter;
|
|
|
+import com.rong.io.live.helper.LiveMemberHelper;
|
|
|
+import com.rong.io.live.helper.LiveMessageHelper;
|
|
|
import com.rong.io.live.helper.LiveRTCEngineInitHelper;
|
|
|
import com.cooleshow.student.widgets.dialog.LiveRoomCloseMicTipDialog;
|
|
|
import com.cooleshow.student.widgets.dialog.LiveRoomClosePageOnMicTipDialog;
|
|
@@ -61,6 +64,8 @@ import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
import com.rong.io.live.LiveRoomMsgConstants;
|
|
|
import com.rong.io.live.config.LiveConfig;
|
|
|
import com.rong.io.live.helper.LiveEventHelper;
|
|
|
+import com.rong.io.live.message.RCChatJoinRoomMessage;
|
|
|
+import com.rong.io.live.message.RCOnSnappingUpMessage;
|
|
|
import com.rong.io.live.message.RCUserKickOutMessage;
|
|
|
import com.rong.io.live.message.RCUserLogOutUnusualMessage;
|
|
|
import com.rong.io.live.message.RCUserSeatApplyMessage;
|
|
@@ -86,6 +91,7 @@ import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
|
|
import cn.rongcloud.rtc.api.RCRTCRoom;
|
|
|
import cn.rongcloud.rtc.api.RCRTCVideoStream;
|
|
|
import cn.rongcloud.rtc.api.stream.RCRTCAudioInputStream;
|
|
|
+import cn.rongcloud.rtc.api.stream.RCRTCAudioOutputStream;
|
|
|
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
|
|
|
import cn.rongcloud.rtc.api.stream.RCRTCVideoInputStream;
|
|
|
import cn.rongcloud.rtc.api.stream.RCRTCVideoOutputStream;
|
|
@@ -137,6 +143,10 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
ImageView mIvShopCar;
|
|
|
ImageView mIvClose;
|
|
|
TextView tv_input;
|
|
|
+ FrameLayout mFlJoinBarrage;
|
|
|
+ TextView mTvJoinBarrage;
|
|
|
+ FrameLayout mFlSnapUpBarrage;
|
|
|
+ TextView mTvSnapUpBarrage;
|
|
|
|
|
|
private LiveRoomInfoBean mRoomInfoBean;
|
|
|
private String mRoomId;
|
|
@@ -146,6 +156,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
private boolean isEnableMic = false;//默认不禁止
|
|
|
private boolean isEnableAll = false;//默认不禁止 黑名单状态
|
|
|
private InputBarDialog mInputBarDialog;
|
|
|
+ private boolean isPcClientLive = true;//默认为PC端直播
|
|
|
private int currentSeatStatus = LiveRoomMsgConstants.MIC_STATUS_NORMAL;//1未连麦,2连麦中,3连麦成功
|
|
|
private LiveRoomCloseMicTipDialog mRoomCloseMicTipDialog;
|
|
|
private LiveRoomInviteSeatMicTipDialog mInviteSeatMicTipDialog;
|
|
@@ -246,6 +257,10 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
mIvShopCar = viewBinding.ivShopCar;
|
|
|
mIvClose = viewBinding.ivClose;
|
|
|
tv_input = viewBinding.tvInput;
|
|
|
+ mFlJoinBarrage = viewBinding.flJoinBarrage;
|
|
|
+ mTvJoinBarrage = viewBinding.tvJoinBarrage;
|
|
|
+ mFlSnapUpBarrage = viewBinding.flSnapUpBarrage;
|
|
|
+ mTvSnapUpBarrage = viewBinding.tvSnapUpBarrage;
|
|
|
initListener();
|
|
|
}
|
|
|
|
|
@@ -300,6 +315,14 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
mRecyclerMsg.setAdapter(mMessageAdapter);
|
|
|
IMCenter.getInstance().addConnectionStatusListener(connectStatusListener);
|
|
|
SoftKeyboardUtil.registerSoftInputChangedListener(getWindow(), this);
|
|
|
+ mLlMicContainer.setOnEventListener(new LiveRoomMicIconView.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void getUserInfoByUserId(String userId) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.getUserInfoByUserId(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
prepareInitRoom();
|
|
|
}
|
|
|
|
|
@@ -541,13 +564,22 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
if (mInputBarDialog == null) {
|
|
|
mInputBarDialog = new InputBarDialog(LiveRoomActivity.this, new InputBar.InputBarListener() {
|
|
|
@Override
|
|
|
- public void onClickSend(String message) {
|
|
|
+ public boolean onClickSend(String message) {
|
|
|
//发送消息
|
|
|
if (TextUtils.isEmpty(message)) {
|
|
|
ToastUtil.getInstance().show(LiveRoomActivity.this, "消息不能为空");
|
|
|
- return;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (message.length() > LiveConfig.LIVE_MAX_INPUT_TEXT_LENGTH) {
|
|
|
+ ToastUtil.getInstance().show(LiveRoomActivity.this, "聊天消息需在40个字以内哦");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (LiveMessageHelper.isQuickAction()) {
|
|
|
+ ToastUtil.getInstance().show(LiveRoomActivity.this, "您说话太快啦");
|
|
|
+ return false;
|
|
|
}
|
|
|
sendTextMessage(message);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -625,8 +657,8 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
if (roomInfoBean == null || isFinishing() || isDestroyed()) {
|
|
|
return;
|
|
|
}
|
|
|
- boolean isPc = !TextUtils.equals("pc", roomInfoBean.os);
|
|
|
- resetVideoContainer(isPc);
|
|
|
+ isPcClientLive = TextUtils.equals(mRoomInfoBean.os, "pc");
|
|
|
+ resetVideoContainer(!isPcClientLive);
|
|
|
mRoomInfoBean = roomInfoBean;
|
|
|
currentAddLikeCount = roomInfoBean.likeNum;
|
|
|
if (!TextUtils.isEmpty(roomInfoBean.roomConfig)) {
|
|
@@ -636,6 +668,17 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
int micCtrlMode = jsonObject.optInt("whether_mic", 0);
|
|
|
isEnableChat = chatCtrlMode == 1;
|
|
|
isEnableMic = micCtrlMode == 1;
|
|
|
+ //购物车是否显示
|
|
|
+ int shopCarMode = jsonObject.optInt("whether_view_shop_cart", 0);
|
|
|
+ if (shopCarMode == 1) {
|
|
|
+ //隐藏购物车
|
|
|
+ mViewShopCarAnim.setVisibility(View.GONE);
|
|
|
+ mIvShopCar.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ //显示购物车
|
|
|
+ mViewShopCarAnim.setVisibility(View.VISIBLE);
|
|
|
+ mIvShopCar.setVisibility(View.INVISIBLE);
|
|
|
+ }
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -644,7 +687,8 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
isEnableAll = roomInfoBean.blacklistFlag == 1;//1是黑名单 0否
|
|
|
updateInputTip();
|
|
|
updateAddLikeCountView();
|
|
|
-
|
|
|
+ //更新未上麦状态
|
|
|
+ updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_NORMAL);
|
|
|
if (mTvNumPeople != null) {
|
|
|
int peopleCount = roomInfoBean.lookNum + 1;//加上自己
|
|
|
mTvNumPeople.setText(peopleCount + "人");
|
|
@@ -714,13 +758,34 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
mVideoViewManager.setIsNeedFillScreen(isFullScreen);
|
|
|
}
|
|
|
if (isFullScreen) {
|
|
|
- mGroupViews.setVisibility(View.GONE);
|
|
|
- mIvClose.setVisibility(View.GONE);
|
|
|
- mIvSwitchVideoOrientation.setVisibility(View.GONE);
|
|
|
- mIvSwitchVideoOrientationFull.setVisibility(View.VISIBLE);
|
|
|
+ if (isPcClientLive) {
|
|
|
+ //隐藏消息列表
|
|
|
+ mGroupViews.setVisibility(View.GONE);
|
|
|
+ mIvClose.setVisibility(View.GONE);
|
|
|
+ //隐藏弹幕消息
|
|
|
+ mFlJoinBarrage.clearAnimation();
|
|
|
+ mFlJoinBarrage.setVisibility(View.GONE);
|
|
|
+ mFlSnapUpBarrage.clearAnimation();
|
|
|
+ mFlSnapUpBarrage.setVisibility(View.GONE);
|
|
|
+ //隐藏竖屏全屏按钮
|
|
|
+ mIvSwitchVideoOrientation.setVisibility(View.GONE);
|
|
|
+ mIvSwitchVideoOrientationFull.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ //不是PC端直播
|
|
|
+ mIvSwitchVideoOrientation.setVisibility(View.GONE);
|
|
|
+ mIvSwitchVideoOrientationFull.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
ConstraintSet set = new ConstraintSet();
|
|
|
set.clone(content_view);
|
|
|
set.clear(mFlLiveView.getId());
|
|
|
+ if (!isPcClientLive) {
|
|
|
+ //如果是非PC端直播,还需要设置下消息列表控件位置
|
|
|
+ set.clear(R.id.fl_recycler_container);
|
|
|
+ set.connect(R.id.fl_recycler_container, ConstraintSet.TOP, R.id.view_center, ConstraintSet.BOTTOM, SizeUtils.dp2px(50));
|
|
|
+ set.connect(R.id.fl_recycler_container, ConstraintSet.LEFT, content_view.getId(), ConstraintSet.LEFT, 0);
|
|
|
+ set.connect(R.id.fl_recycler_container, ConstraintSet.RIGHT, content_view.getId(), ConstraintSet.RIGHT, 0);
|
|
|
+ set.connect(R.id.fl_recycler_container, ConstraintSet.BOTTOM, tv_input.getId(), ConstraintSet.TOP, SizeUtils.dp2px(10));
|
|
|
+ }
|
|
|
set.connect(mFlLiveView.getId(), ConstraintSet.TOP, content_view.getId(), ConstraintSet.TOP, 0);
|
|
|
set.connect(mFlLiveView.getId(), ConstraintSet.LEFT, content_view.getId(), ConstraintSet.LEFT, 0);
|
|
|
set.connect(mFlLiveView.getId(), ConstraintSet.RIGHT, content_view.getId(), ConstraintSet.RIGHT, 0);
|
|
@@ -732,10 +797,13 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
//还原显示头部信息
|
|
|
handleHeaderAnim();
|
|
|
}
|
|
|
- mGroupViews.setVisibility(View.VISIBLE);
|
|
|
- mIvClose.setVisibility(View.VISIBLE);
|
|
|
- mIvSwitchVideoOrientation.setVisibility(View.VISIBLE);
|
|
|
- mIvSwitchVideoOrientationFull.setVisibility(View.GONE);
|
|
|
+ if (isPcClientLive) {
|
|
|
+ mGroupViews.setVisibility(View.VISIBLE);
|
|
|
+ mIvClose.setVisibility(View.VISIBLE);
|
|
|
+ mIvSwitchVideoOrientation.setVisibility(View.VISIBLE);
|
|
|
+ mIvSwitchVideoOrientationFull.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
ConstraintSet set = new ConstraintSet();
|
|
|
set.clone(content_view);
|
|
|
set.clear(mFlLiveView.getId());
|
|
@@ -746,7 +814,6 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
set.constrainHeight(mFlLiveView.getId(), maxHeightAtRatio16_9);
|
|
|
set.applyTo(content_view);
|
|
|
}
|
|
|
- changVideoViewSize();
|
|
|
}
|
|
|
|
|
|
public void changVideoViewSize() {
|
|
@@ -965,6 +1032,20 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void onRemoteUserPublishResource(String remoteUserId) {
|
|
|
+ if (!TextUtils.isEmpty(remoteUserId)) {
|
|
|
+ Log.i("pq", "收到onRemoteUserPublishResource:" + remoteUserId);
|
|
|
+ if (mRoomInfoBean != null && TextUtils.equals(mRoomInfoBean.speakerId, remoteUserId)) {
|
|
|
+ if (presenter != null) {
|
|
|
+ presenter.subscribeAVStream();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ refreshAudio(null, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void syncMemberCount(String count) {
|
|
|
//同步成员数量
|
|
|
Log.i("pq", "syncMemberCount" + count);
|
|
@@ -1017,11 +1098,15 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
}
|
|
|
|
|
|
private void refresh() {
|
|
|
+ //video流信息
|
|
|
List<RCRTCVideoOutputStream> outputStreams = new ArrayList<>();
|
|
|
- List<RCRTCVideoInputStream> input = new ArrayList<>();
|
|
|
+ List<RCRTCVideoInputStream> videoInputStreams = new ArrayList<>();
|
|
|
+ //音频流信息
|
|
|
List<RCRTCAudioInputStream> audioinputstream = new ArrayList<>();
|
|
|
- presenter.getVideoStream(outputStreams, input, audioinputstream);
|
|
|
- updateVideoView(outputStreams, input, audioinputstream);
|
|
|
+ List<RCRTCAudioOutputStream> audioOutputStreams = new ArrayList<>();
|
|
|
+ presenter.getAllStreams(outputStreams, videoInputStreams, audioinputstream, audioOutputStreams);
|
|
|
+ updateVideoView(outputStreams, videoInputStreams, audioinputstream, audioOutputStreams);
|
|
|
+ refreshAudio(audioinputstream, audioOutputStreams);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1047,27 +1132,6 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void notifyMicContainerAdd(String userId, String userName) {
|
|
|
- mLlMicContainer.post(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- String lastName = userName;
|
|
|
- UserInfo targetUser = mLlMicContainer.getUserInfoIfExist(userId);
|
|
|
- if (targetUser != null && !TextUtils.equals(targetUser.getName(), LiveRoomMicIconView.DEFAULT_NICK)) {
|
|
|
- lastName = targetUser.getName();
|
|
|
- } else {
|
|
|
- if (TextUtils.isEmpty(lastName)) {
|
|
|
- //如果昵称为空,查询昵称
|
|
|
- if (presenter != null) {
|
|
|
- presenter.getUserInfoByUserId(userId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- mLlMicContainer.addMicUser(new UserInfo(userId, lastName, null));
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
private void notifyMicContainerDel(String userId) {
|
|
|
mLlMicContainer.post(new Runnable() {
|
|
|
@Override
|
|
@@ -1083,7 +1147,6 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
@Override
|
|
|
public void onSeatMicSuccess() {
|
|
|
updateMicIcon(LiveRoomMsgConstants.MIC_STATUS_CONNECT_SUCCESS);
|
|
|
- notifyMicContainerAdd(mUserId, UserHelper.getUserName());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1202,7 +1265,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
return;
|
|
|
}
|
|
|
if (mLlMicContainer != null) {
|
|
|
- mLlMicContainer.addMicUser(new UserInfo(friendInfoBean.friendId, friendInfoBean.friendNickname, null));
|
|
|
+ mLlMicContainer.updateTargetUserInfo(new UserInfo(friendInfoBean.friendId, friendInfoBean.friendNickname, null));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1274,8 +1337,45 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
mInviteSeatMicTipDialog.setContent(defaultNick);
|
|
|
}
|
|
|
|
|
|
+ private void refreshAudio(List<RCRTCAudioInputStream> audioInputStreams, List<RCRTCAudioOutputStream> audioOutputStreams) {
|
|
|
+ if (audioInputStreams == null || audioOutputStreams == null) {
|
|
|
+ //参数为空,先获取房间里的全部音频流信息
|
|
|
+ audioInputStreams = new ArrayList<>();
|
|
|
+ audioOutputStreams = new ArrayList<>();
|
|
|
+ presenter.getAudioStreams(audioInputStreams, audioOutputStreams);
|
|
|
+ }
|
|
|
+ ArrayList<String> onMicUserIds = new ArrayList<>();
|
|
|
+ //先处理本地用户
|
|
|
+ for (int i = 0; i < audioOutputStreams.size(); i++) {
|
|
|
+ RCRTCAudioOutputStream audioInputStream = audioOutputStreams.get(i);
|
|
|
+ if (audioInputStream.getMediaType() == RCRTCMediaType.AUDIO) {
|
|
|
+ //音频流判断显示上麦用户
|
|
|
+ String userId = audioInputStream.getUserId();
|
|
|
+ if (mRoomInfoBean != null) {
|
|
|
+ if (!TextUtils.equals(mRoomInfoBean.speakerId, userId)) {
|
|
|
+ onMicUserIds.add(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //远端用户的音频流信息
|
|
|
+ for (int i = 0; i < audioInputStreams.size(); i++) {
|
|
|
+ RCRTCAudioInputStream rcrtcAudioInputStream = audioInputStreams.get(i);
|
|
|
+ if (rcrtcAudioInputStream.getMediaType() == RCRTCMediaType.AUDIO) {
|
|
|
+ //音频流判断显示上麦用户
|
|
|
+ String userId = rcrtcAudioInputStream.getUserId();
|
|
|
+ if (mRoomInfoBean != null) {
|
|
|
+ if (!TextUtils.equals(mRoomInfoBean.speakerId, userId)) {
|
|
|
+ onMicUserIds.add(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mLlMicContainer.refreshUI(onMicUserIds);
|
|
|
+ }
|
|
|
|
|
|
- public void updateVideoView(List<RCRTCVideoOutputStream> outputStreams, List<RCRTCVideoInputStream> inputStreams, List<RCRTCAudioInputStream> audioInputStreams) {
|
|
|
+ public void updateVideoView(List<RCRTCVideoOutputStream> outputStreams, List<RCRTCVideoInputStream> inputStreams, List<RCRTCAudioInputStream> audioInputStreams, List<RCRTCAudioOutputStream> audioOutputStreams) {
|
|
|
mFlLiveView.post(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -1283,9 +1383,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
videoStreams.addAll(outputStreams);
|
|
|
videoStreams.addAll(inputStreams);
|
|
|
ArrayList<RCRTCVideoView> list = new ArrayList<>();
|
|
|
- ArrayList<String> otherAudioUserIds = new ArrayList<>();
|
|
|
boolean isNormalCreateAudioStatus = true;
|
|
|
-
|
|
|
//视频流
|
|
|
for (int i = 0; i < videoStreams.size(); i++) {
|
|
|
RCRTCVideoStream rcrtcVideoStream = videoStreams.get(i);
|
|
@@ -1300,35 +1398,20 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
if (audioInputStream.getMediaType() == RCRTCMediaType.AUDIO) {
|
|
|
//音频流判断显示上麦用户
|
|
|
String userId = audioInputStream.getUserId();
|
|
|
- if (TextUtils.equals(mUserId, userId)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
if (mRoomInfoBean != null) {
|
|
|
- if (!TextUtils.equals(mRoomInfoBean.speakerId, userId)) {
|
|
|
- otherAudioUserIds.add(userId);
|
|
|
- } else {
|
|
|
- //主播的音频流
|
|
|
+ if (TextUtils.equals(mRoomInfoBean.speakerId, userId)) {
|
|
|
+ //找出主播的音频流
|
|
|
RCRTCResourceState resourceState = audioInputStream.getResourceState();
|
|
|
isNormalCreateAudioStatus = resourceState == RCRTCResourceState.NORMAL;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (otherAudioUserIds.size() != 0) {
|
|
|
- mLlMicContainer.delAllExcludeOwn();
|
|
|
- for (int i = 0; i < otherAudioUserIds.size(); i++) {
|
|
|
- String onMicUserId = otherAudioUserIds.get(i);
|
|
|
- notifyMicContainerAdd(onMicUserId, "");
|
|
|
- }
|
|
|
- } else {
|
|
|
- mLlMicContainer.delAllExcludeOwn();
|
|
|
- }
|
|
|
if (list.size() != 0) {
|
|
|
creatorIsCloseVideoStream = false;
|
|
|
mViewLiveStatus.setVisibility(View.GONE);
|
|
|
checkVideoViewManager();
|
|
|
- mVideoViewManager.update(list, 0, true);
|
|
|
+ mVideoViewManager.update(list, isPcClientLive, true);
|
|
|
} else {
|
|
|
creatorIsCloseVideoStream = true;
|
|
|
if (isNormalCreateAudioStatus) {
|
|
@@ -1371,85 +1454,6 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 当远端或本端视频流发生变化时全量更新ui
|
|
|
- */
|
|
|
- void updateVideoView(List<RCRTCInputStream> inputStreams) {
|
|
|
- mFlLiveView.post(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- hideLoading();
|
|
|
- ArrayList<RCRTCVideoView> list = new ArrayList<>();
|
|
|
- ArrayList<String> otherAudioUserIds = new ArrayList<>();
|
|
|
- boolean isNormalCreateAudioStatus = true;
|
|
|
- if (null != inputStreams) {
|
|
|
- for (RCRTCInputStream i : inputStreams) {
|
|
|
- if (i.getMediaType() == RCRTCMediaType.VIDEO) {
|
|
|
-// if (mRoomInfoBean != null) {
|
|
|
-// if (TextUtils.equals(createRoomId, i.getUserId())) {
|
|
|
-// Log.i("pq","已存在相同的流,无须重复渲染");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// }
|
|
|
- RCRTCVideoInputStream j = (RCRTCVideoInputStream) i;
|
|
|
- RCRTCVideoView rongRTCVideoView = new RCRTCVideoView(LiveRoomActivity.this);
|
|
|
- j.setVideoView(rongRTCVideoView);
|
|
|
- createRoomId = j.getUserId();
|
|
|
- list.add(rongRTCVideoView);
|
|
|
- }
|
|
|
-
|
|
|
- if (i.getMediaType() == RCRTCMediaType.AUDIO) {
|
|
|
- //音频流判断显示上麦用户
|
|
|
- String userId = i.getUserId();
|
|
|
- if (TextUtils.equals(mUserId, userId)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (mRoomInfoBean != null) {
|
|
|
- if (!TextUtils.equals(mRoomInfoBean.speakerId, userId)) {
|
|
|
- otherAudioUserIds.add(userId);
|
|
|
- } else {
|
|
|
- //主播的音频流
|
|
|
- RCRTCAudioInputStream rcrtcAudioInputStream = (RCRTCAudioInputStream) i;
|
|
|
- RCRTCResourceState resourceState = rcrtcAudioInputStream.getResourceState();
|
|
|
- isNormalCreateAudioStatus = resourceState == RCRTCResourceState.NORMAL;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (otherAudioUserIds.size() != 0) {
|
|
|
- mLlMicContainer.delAllExcludeOwn();
|
|
|
- for (int i = 0; i < otherAudioUserIds.size(); i++) {
|
|
|
- String onMicUserId = otherAudioUserIds.get(i);
|
|
|
- notifyMicContainerAdd(onMicUserId, "");
|
|
|
- }
|
|
|
- } else {
|
|
|
- mLlMicContainer.delAllExcludeOwn();
|
|
|
- }
|
|
|
- if (list.size() != 0) {
|
|
|
- creatorIsCloseVideoStream = false;
|
|
|
- mViewLiveStatus.setVisibility(View.GONE);
|
|
|
- RCRTCVideoView rcrtcVideoView = list.get(list.size() - 1);
|
|
|
- mFlLiveView.removeAllViews();
|
|
|
-// mFlLiveView.addView(rcrtcVideoView);
|
|
|
- rcrtcVideoView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
|
|
|
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
|
- params.addRule(RelativeLayout.CENTER_IN_PARENT);
|
|
|
- // 将远端视图添加至布局
|
|
|
- mFlLiveView.addView(rcrtcVideoView, params);
|
|
|
- } else {
|
|
|
- creatorIsCloseVideoStream = true;
|
|
|
- if (isNormalCreateAudioStatus) {
|
|
|
- showCloseVideoView();
|
|
|
- } else {
|
|
|
- //主播关闭了视频流,同时音频流的状态也不是normal状态时
|
|
|
- showRestView();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
protected void onSaveInstanceState(Bundle outState) {
|
|
|
super.onSaveInstanceState(outState);
|
|
@@ -1527,6 +1531,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
if (mVideoViewManager != null && mVideoViewManager.getAllVideoViews() != null && mVideoViewManager.getAllVideoViews().size() > 0) {
|
|
|
Intent intent = new Intent(this, FloatingWindowService.class);
|
|
|
initServiceConnection();
|
|
|
+ intent.putExtra("isPc", isPcClientLive);
|
|
|
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
|
|
|
}
|
|
|
}
|
|
@@ -1547,7 +1552,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
@Override
|
|
|
public void onServiceDestroy() {
|
|
|
if (mVideoViewManager != null) {
|
|
|
- mVideoViewManager.update(mVideoViewManager.getAllVideoViews(), 0, false);
|
|
|
+ mVideoViewManager.update(mVideoViewManager.getAllVideoViews(), isPcClientLive, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1563,7 +1568,7 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
@Override
|
|
|
public void onServiceDisconnected(ComponentName name) {
|
|
|
if (mVideoViewManager != null) {
|
|
|
- mVideoViewManager.update(mVideoViewManager.getAllVideoViews(), 0, false);
|
|
|
+ mVideoViewManager.update(mVideoViewManager.getAllVideoViews(), isPcClientLive, false);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -1657,6 +1662,76 @@ public class LiveRoomActivity extends BaseMVPActivity<ActivityLiveroomLayoutBind
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void receiveJoinMessage(RCChatJoinRoomMessage joinRoomMessage) {
|
|
|
+ //收到加入房间消息
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (joinRoomMessage == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isCanShowBarrage()) {
|
|
|
+ mTvJoinBarrage.setText(getString(R.string.enter_live_tip_str, LiveMemberHelper.getMessageName(joinRoomMessage)));
|
|
|
+ showBarrageViewAnim(mFlJoinBarrage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示弹幕消息
|
|
|
+ */
|
|
|
+ private void showBarrageViewAnim(View targetView) {
|
|
|
+ if (mFlJoinBarrage.getVisibility() == View.VISIBLE || mFlSnapUpBarrage.getVisibility() == View.VISIBLE) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LiveRoomAnimatorHelper.getInstance().startBarrageViewAnimation(this, targetView);
|
|
|
+ hideBarrageView();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 隐藏弹幕消息
|
|
|
+ */
|
|
|
+ private void hideBarrageView() {
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ if (mFlJoinBarrage != null) {
|
|
|
+ mFlJoinBarrage.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ if (mFlSnapUpBarrage != null) {
|
|
|
+ mFlSnapUpBarrage.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, LiveConfig.LIVE_HIDE_BARRAGE_VIEW_TIME);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void receiveSnapUpMessage(RCOnSnappingUpMessage onSnappingUpMessage) {
|
|
|
+ //收到抢购消息
|
|
|
+ if (isFinishing() || isDestroyed()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (onSnappingUpMessage == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isCanShowBarrage()) {
|
|
|
+ mTvSnapUpBarrage.setText(getString(R.string.live_snap_up_tip_str, LiveMemberHelper.getMessageName(onSnappingUpMessage)));
|
|
|
+ showBarrageViewAnim(mFlSnapUpBarrage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否显示弹幕消息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean isCanShowBarrage() {
|
|
|
+ if (isFullScreen()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return mFlJoinBarrage.getVisibility() != View.VISIBLE && mFlSnapUpBarrage.getVisibility() != View.VISIBLE;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void onDestroy() {
|
|
|
if (presenter != null) {
|
|
|
//通知离开房间
|