更新多人连麦主播端部分代码注释
限制多人连麦直播端仅允许同意/邀请三人
This commit is contained in:
parent
d42835231e
commit
91fdef55c7
@ -66,6 +66,7 @@ import com.yunbao.live.bean.LiveGuardInfo;
|
|||||||
import com.yunbao.live.bean.LiveKsyConfigBean;
|
import com.yunbao.live.bean.LiveKsyConfigBean;
|
||||||
import com.yunbao.live.bean.LiveReceiveGiftBean;
|
import com.yunbao.live.bean.LiveReceiveGiftBean;
|
||||||
import com.yunbao.live.bean.LiveUserGiftBean;
|
import com.yunbao.live.bean.LiveUserGiftBean;
|
||||||
|
import com.yunbao.live.bean.MicUserBean;
|
||||||
import com.yunbao.live.dialog.LiveLinkMicListDialogFragment;
|
import com.yunbao.live.dialog.LiveLinkMicListDialogFragment;
|
||||||
import com.yunbao.live.dialog.LiveMicAnchorDialogFragment;
|
import com.yunbao.live.dialog.LiveMicAnchorDialogFragment;
|
||||||
import com.yunbao.live.dialog.LiveNewFunctionDialogFragment;
|
import com.yunbao.live.dialog.LiveNewFunctionDialogFragment;
|
||||||
@ -1355,4 +1356,26 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查指定直播间连麦人数
|
||||||
|
*
|
||||||
|
* @param mLiveUid 直播间
|
||||||
|
*/
|
||||||
|
public static void checkMicUserLength(String mLiveUid, LiveFunctionClickListener listener) {
|
||||||
|
LiveHttpUtil.getMicList(mLiveUid, 0, new HttpCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
|
if (code == 0) {
|
||||||
|
try {
|
||||||
|
JSONObject obj = JSON.parseObject(info[0]);
|
||||||
|
List<MicUserBean> list = JSON.parseArray(obj.getString("userlist"), MicUserBean.class);
|
||||||
|
listener.onClick(list.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,14 @@ import com.yunbao.common.http.API;
|
|||||||
import com.yunbao.common.http.ResponseModel;
|
import com.yunbao.common.http.ResponseModel;
|
||||||
import com.yunbao.common.utils.CommonIconUtil;
|
import com.yunbao.common.utils.CommonIconUtil;
|
||||||
import com.yunbao.common.utils.SVGAViewUtils;
|
import com.yunbao.common.utils.SVGAViewUtils;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.live.R;
|
import com.yunbao.live.R;
|
||||||
import com.yunbao.live.activity.LiveActivity;
|
import com.yunbao.live.activity.LiveActivity;
|
||||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||||
|
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||||
import com.yunbao.live.bean.MicUserBean;
|
import com.yunbao.live.bean.MicUserBean;
|
||||||
import com.yunbao.live.event.LiveRoomChangeEvent;
|
import com.yunbao.live.event.LiveRoomChangeEvent;
|
||||||
|
import com.yunbao.live.interfaces.LiveFunctionClickListener;
|
||||||
import com.yunbao.live.socket.SocketSendBean;
|
import com.yunbao.live.socket.SocketSendBean;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -116,12 +119,23 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
|
|||||||
mBtn.setOnClickListener(v -> {
|
mBtn.setOnClickListener(v -> {
|
||||||
if (v.getTag() != null) {
|
if (v.getTag() != null) {
|
||||||
MicUserBean tag = (MicUserBean) v.getTag();
|
MicUserBean tag = (MicUserBean) v.getTag();
|
||||||
|
LiveRyAnchorActivity.checkMicUserLength(mLiveUid, new LiveFunctionClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(int length) {
|
||||||
|
//只允许最多3人连麦(加主播4人)
|
||||||
|
if (length < 4) {
|
||||||
if (tag.getType() == TYPE_MIC_REQUEST) {
|
if (tag.getType() == TYPE_MIC_REQUEST) {
|
||||||
applyMic(tag, 4, createSocketSendBean());
|
applyMic(tag, 4, createSocketSendBean());
|
||||||
} else if (tag.getType() == TYPE_MIC_INVITE) {
|
} else if (tag.getType() == TYPE_MIC_INVITE) {
|
||||||
SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
|
SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
|
||||||
applyMic(tag, 1, bean);
|
applyMic(tag, 1, bean);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
ToastUtil.show("仅允许三人与主播连麦");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mClose.setOnClickListener(v -> {
|
mClose.setOnClickListener(v -> {
|
||||||
@ -149,6 +163,10 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter<MicUserBean> {
|
|||||||
.param("uid", CommonAppConfig.getInstance().getUid());
|
.param("uid", CommonAppConfig.getInstance().getUid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送IM消息
|
||||||
|
* @param action 4为同意请求,1为邀请,其余见 {@link com.yunbao.live.socket.SocketRyClient} Constants.LIAN_MAI解析
|
||||||
|
*/
|
||||||
void applyMic(MicUserBean bean, int action, SocketSendBean msg) {
|
void applyMic(MicUserBean bean, int action, SocketSendBean msg) {
|
||||||
msg.param("action", action);
|
msg.param("action", action);
|
||||||
msg.create();
|
msg.create();
|
||||||
|
@ -153,9 +153,7 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
|
|||||||
mNoMoreDesc = mRootView.findViewById(R.id.no_more_desc);
|
mNoMoreDesc = mRootView.findViewById(R.id.no_more_desc);
|
||||||
Tips = bundle.getString("By");
|
Tips = bundle.getString("By");
|
||||||
|
|
||||||
listMicbtn.setOnClickListener(new View.OnClickListener() {
|
listMicbtn.setOnClickListener(view -> {
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (!isOpenRoom()) {
|
if (!isOpenRoom()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -163,12 +161,9 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
|
|||||||
Up();
|
Up();
|
||||||
type = "guanzhong";
|
type = "guanzhong";
|
||||||
mRefreshView.initData();
|
mRefreshView.initData();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
requestMicBtn = mRootView.findViewById(R.id.guard_btn);
|
requestMicBtn = mRootView.findViewById(R.id.guard_btn);
|
||||||
requestMicBtn.setOnClickListener(new View.OnClickListener() {
|
requestMicBtn.setOnClickListener(view -> {
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (!isOpenRoom()) {
|
if (!isOpenRoom()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -176,13 +171,10 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
|
|||||||
Up();
|
Up();
|
||||||
type = "guard";
|
type = "guard";
|
||||||
mRefreshView.initData();
|
mRefreshView.initData();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
inviteMicBtn = mRootView.findViewById(R.id.fans_btn);
|
inviteMicBtn = mRootView.findViewById(R.id.fans_btn);
|
||||||
inviteMicBtn.setVisibility(View.VISIBLE);
|
inviteMicBtn.setVisibility(View.VISIBLE);
|
||||||
inviteMicBtn.setOnClickListener(new View.OnClickListener() {
|
inviteMicBtn.setOnClickListener(view -> {
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
if (!isOpenRoom()) {
|
if (!isOpenRoom()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -190,7 +182,6 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
|
|||||||
Up();
|
Up();
|
||||||
type = "fans";
|
type = "fans";
|
||||||
mRefreshView.initData();
|
mRefreshView.initData();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
mOpenMicBtn.setOnClickListener(v -> {
|
mOpenMicBtn.setOnClickListener(v -> {
|
||||||
API.get().pdLiveApi(mContext)
|
API.get().pdLiveApi(mContext)
|
||||||
@ -362,6 +353,7 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(int code, String msg, String[] info) {
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
|
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
|
||||||
|
//非0认为未开通连麦权限
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
mOpenMicLayout.setVisibility(View.VISIBLE);
|
mOpenMicLayout.setVisibility(View.VISIBLE);
|
||||||
mRefreshView.setVisibility(View.GONE);
|
mRefreshView.setVisibility(View.GONE);
|
||||||
@ -399,6 +391,9 @@ public class LiveMicAnchorDialogFragment extends AbsDialogFragment implements Vi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于更新连麦对话框数据
|
||||||
|
*/
|
||||||
public interface OnMicListener {
|
public interface OnMicListener {
|
||||||
void updateMicList(TreeMap<String, LinkMicUserBean> list);
|
void updateMicList(TreeMap<String, LinkMicUserBean> list);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user