add[声望升级-多人PK]
This commit is contained in:
parent
d78055cdd9
commit
95ded2f77c
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@ -190,6 +190,8 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode;
|
||||
-keep class org.greenrobot.eventbus.android.AndroidComponentsImpl*
|
||||
|
||||
#--------ARouter
|
||||
|
||||
-keep public class com.alibaba.android.arouter.**{*;}
|
||||
-keep public class com.alibaba.android.arouter.routes.**{*;}
|
||||
-keep public class com.alibaba.android.arouter.facade.**{*;}
|
||||
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
|
||||
|
@ -153,20 +153,22 @@ public class SWManager extends BaseCacheManager {
|
||||
switch (selectClarity) {
|
||||
case 0:
|
||||
cfg.dimensions = VideoEncoderConfiguration.VD_840x480;
|
||||
L.eSw("VideoEncoderConfiguration.VD_840x480");
|
||||
break;
|
||||
case 1:
|
||||
cfg.dimensions = VideoEncoderConfiguration.VD_1280x720;
|
||||
L.eSw("VideoEncoderConfiguration.VD_1280x720");
|
||||
break;
|
||||
case 2:
|
||||
cfg.dimensions = VideoEncoderConfiguration.VD_1920x1080;
|
||||
L.eSw("VideoEncoderConfiguration.VD_1920x1080");
|
||||
break;
|
||||
case 3:
|
||||
cfg.dimensions = VideoEncoderConfiguration.VD_320x240;
|
||||
L.eSw("VideoEncoderConfiguration.VD_320x240");
|
||||
break;
|
||||
}
|
||||
mRtcEngine.setVideoEncoderConfiguration(cfg);
|
||||
// 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象
|
||||
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||
anchorContainer.addView(surfaceView);
|
||||
// 设置视图
|
||||
mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +243,7 @@ public class SWManager extends BaseCacheManager {
|
||||
// 创建 ChannelMediaOptions 对象,并进行配置
|
||||
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||
// 根据场景将用户角色设置为 AUDIENCE (观众)
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
|
||||
options.autoSubscribeVideo = true;
|
||||
options.autoSubscribeAudio = true;
|
||||
options.publishMicrophoneTrack = false;
|
||||
|
@ -1314,7 +1314,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
if (mLiveAnchorViewHolder != null) {
|
||||
mLiveAnchorViewHolder.setYaoqing(pkUid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1041,7 +1041,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
}
|
||||
JSONObject obj = JSONObject.parseObject(info[0]);
|
||||
drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
|
||||
|
||||
SWManager.get().setDimensions(3);//加入成功后,将分别率设置为 VD_320x240
|
||||
//将自己从多人pk列表里剔除
|
||||
int removeIndex = -1;
|
||||
for (int i = 0; i < drPkbeans.size(); i++) {
|
||||
@ -1066,12 +1066,12 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
.param("action", 2)
|
||||
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
|
||||
.param("pkuid", CommonAppConfig.getInstance().getUid())
|
||||
.param("type", 2)
|
||||
.param("msgtype", 2)
|
||||
.param("uid", drPkbeans.get(i).getId())
|
||||
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
|
||||
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
||||
msg1.create();
|
||||
|
||||
L.eSw("uiduiduiduiduiduiduiduid"+drPkbeans.get(i).getId());
|
||||
String targetId = String.valueOf(drPkbeans.get(i).getId());
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
@ -1093,24 +1093,27 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
int index = livePushRyViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1);
|
||||
|
||||
L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 1 " + u.getUserNiceName());
|
||||
L.eSw("發送action = 2");
|
||||
|
||||
}
|
||||
if(!mApplyUid.equals(String.valueOf(drPkbeans.get(i).getId()))&&!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))){
|
||||
|
||||
if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
|
||||
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK)
|
||||
.param("action", 3)
|
||||
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
|
||||
.param("pkuid", CommonAppConfig.getInstance().getUid())
|
||||
.param("type", 3)
|
||||
.param("msgtype", 3)
|
||||
.param("uid", drPkbeans.get(i).getId())
|
||||
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
|
||||
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
||||
msg1.create();
|
||||
|
||||
String targetId = "g" + drPkbeans.get(i).getId();
|
||||
L.eSw("發送給自己直播間"+drPkbeans.get(i).getId());
|
||||
String targetId = "g" + CommonAppConfig.getInstance().getUid();
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; //群聊
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
|
||||
@ -1132,18 +1135,20 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
if(!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))){
|
||||
|
||||
|
||||
if(!mApplyUid.equals(String.valueOf(drPkbeans.get(i).getId()))&&!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))){
|
||||
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK)
|
||||
.param("action", 3)
|
||||
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
|
||||
.param("pkuid", CommonAppConfig.getInstance().getUid())
|
||||
.param("type", 3)
|
||||
.param("msgtype", 3)
|
||||
.param("uid", drPkbeans.get(i).getId())
|
||||
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
|
||||
.param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
|
||||
msg1.create();
|
||||
|
||||
String targetId = "g" + CommonAppConfig.getInstance().getUid();
|
||||
L.eSw("發送給其他主播直播间"+drPkbeans.get(i).getId());
|
||||
String targetId = "g" + drPkbeans.get(i).getId();
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; //群聊
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
|
||||
@ -1156,7 +1161,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
public void onSuccess(io.rong.imlib.model.Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import android.widget.LinearLayout;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.imsdk.v2.V2TIMCallback;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
@ -760,6 +761,7 @@ public class SocketClient {
|
||||
*/
|
||||
private static void processAnchorLinkMicPk(JSONObject map) {
|
||||
int action = map.getIntValue("action");
|
||||
L.eSw(new Gson().toJson(map));
|
||||
switch (action) {
|
||||
case 1://收到对方主播发起PK回调
|
||||
UserBean u = new UserBean();
|
||||
|
@ -257,6 +257,7 @@ public interface SocketMessageListener {
|
||||
*/
|
||||
void onLinkMicPkClose(int i);
|
||||
|
||||
|
||||
/**
|
||||
* 主播与主播PK 对方主播拒绝pk的回调
|
||||
*/
|
||||
|
@ -88,6 +88,7 @@ import java.util.List;
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
||||
import cn.rongcloud.rtc.base.RTCErrorCode;
|
||||
import io.agora.beautyapi.faceunity.agora.SWManager;
|
||||
import io.rong.imlib.IRongCoreCallback;
|
||||
import io.rong.imlib.IRongCoreEnum;
|
||||
import io.rong.imlib.chatroom.base.RongChatRoomClient;
|
||||
@ -315,12 +316,16 @@ public class SocketRyClient {
|
||||
}
|
||||
//收到对方同意多人PK邀请
|
||||
else if (action3 == 2) {
|
||||
if("0".equals(map.getString("msgtype"))){
|
||||
return;
|
||||
}
|
||||
UserBean u = new UserBean();
|
||||
// u.setUserNiceName(map.getString("uname"));
|
||||
u.setId(map.getString("pkuid"));
|
||||
L.eSw("action3 == 2:"+u.getId());
|
||||
L.eSw("收到对方同意多人PK邀请");
|
||||
mListener.onLinkDRMicPkApplyOk(u);
|
||||
SWManager.get().setDimensions(3);//退出直播间,将分别率设置为 VD_840x480
|
||||
} else if (action3 == 6) {//开始Pk
|
||||
if (LiveRoomViewHolder.mHandler != null) {
|
||||
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
|
||||
@ -343,12 +348,14 @@ public class SocketRyClient {
|
||||
// LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
|
||||
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW));
|
||||
}
|
||||
SWManager.get().setDimensions(0);//退出直播间,将分别率设置为 VD_840x480
|
||||
//創建了多人房間
|
||||
} else if (action3 == 3) {
|
||||
L.eSw("創建了多人房間action3 == 3");
|
||||
/* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||
}*/
|
||||
if(livePushRyViewHolder==null){
|
||||
if("4".equals(map.getString("msgtype"))){
|
||||
return;
|
||||
}
|
||||
@ -362,6 +369,7 @@ public class SocketRyClient {
|
||||
mListener.onLinkDRMicPKToUser(u);
|
||||
Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW));
|
||||
isDRPK = 1;
|
||||
}
|
||||
} else if (action3 == 10) {
|
||||
//显示pk分数
|
||||
if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) {
|
||||
|
@ -252,6 +252,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
ry_view.removeAllViews();
|
||||
swAuManager.updateMyChannelView((FrameLayout) dr1_preview, Integer.parseInt(liveUid));
|
||||
swAuManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId()));
|
||||
dr1_preview.setVisibility(View.VISIBLE);
|
||||
dr2_preview.setVisibility(View.VISIBLE);
|
||||
dr3_preview.setVisibility(View.GONE);
|
||||
dr4_preview.setVisibility(View.GONE);
|
||||
@ -306,10 +307,14 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
|
||||
public void setDrPkView(List<DrPkbean> drPkbeanList){
|
||||
|
||||
if (detailsView1 != null) {
|
||||
dr1_preview.removeView(detailsView1);
|
||||
}
|
||||
|
||||
/*new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
|
||||
detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
|
||||
linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
|
||||
@ -320,9 +325,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
dr1_preview.addView(detailsView1);
|
||||
detailsLinearLayout1.setVisibility(View.VISIBLE);
|
||||
linearGrade1.setVisibility(View.GONE);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (int j = 0; j < drPkbeanList.size(); j++) {
|
||||
if (j == 0) {
|
||||
L.eSw("j == 0:" + j);
|
||||
@ -392,7 +395,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
}, 2000);*/
|
||||
}
|
||||
|
||||
|
||||
@ -407,6 +410,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
mPkContainer.setVisibility(View.GONE);
|
||||
swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid));
|
||||
swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid));
|
||||
ry_view.setVisibility(View.VISIBLE);
|
||||
mLeftContainer.removeAllViews();
|
||||
mRightContainer.removeAllViews();
|
||||
}
|
||||
@ -942,7 +946,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
LiveAudienceActivity.mProcessResultUtil.requestPermissions(permissions, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//UsertoRY();
|
||||
// UsertoRY();
|
||||
//将自己设置成给主播,和主播连麦
|
||||
L.eSw("将自己设置成给主播,和主播连麦");
|
||||
joinLiveMic();
|
||||
@ -1068,18 +1072,17 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 把观众转换成主播
|
||||
*/
|
||||
public List<RCRTCInputStream> userinputStreamList = new ArrayList<>();
|
||||
|
||||
|
||||
public void UsertoRY() {
|
||||
userinputStreamList.clear();
|
||||
Log.e("ry", "主播同意了UsertoRY");
|
||||
if (userJoinLinkMic) {//已经在房间内,不再joinRoom直接去连麦
|
||||
subscribeMic(rcrtcRoom);
|
||||
//subscribeMic(rcrtcRoom);
|
||||
joinLiveMic();
|
||||
return;
|
||||
}
|
||||
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
|
||||
@ -1093,7 +1096,6 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
||||
userJoinLinkMic = true;
|
||||
rcrtcRoom = data;
|
||||
subscribeMic(data);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,6 +88,7 @@ import io.agora.beautyapi.faceunity.agora.SWManager;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
@ -604,6 +605,47 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
swManager.setPkContainer(mRightContainer);
|
||||
swManager.joinChannelEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId()));
|
||||
}
|
||||
HttpClient.getInstance().get("Livepk.setPK", "Livepk.setPK")
|
||||
.params("uid", CommonAppConfig.getInstance().getUid())
|
||||
.params("pkuid", u.getId())
|
||||
.params("type", "1")
|
||||
.params("sign", "1")
|
||||
.execute(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msgs, String[] info) {
|
||||
if (code == 0) {
|
||||
final SocketSendBean msg1 = new SocketSendBean()
|
||||
.param("_method_", Constants.SOCKET_LINK_MIC_PK)
|
||||
.param("action", 4)
|
||||
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
|
||||
.param("pkuid", u.getId())
|
||||
.param("uid", CommonAppConfig.getInstance().getUid());
|
||||
msg1.create();
|
||||
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
Message message1 = Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent);
|
||||
|
||||
RongIMClient.getInstance().sendMessage(message1, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
Log.i("tx", "发送成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int currentPosition = 0;
|
||||
|
@ -5302,6 +5302,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
linearGrade2.setVisibility(View.GONE);
|
||||
linearGrade3.setVisibility(View.GONE);
|
||||
linearGrade4.setVisibility(View.GONE);
|
||||
mRoot.removeView(detailsView);
|
||||
mRoot.addView(detailsView);
|
||||
mRoot.post(new Runnable() {
|
||||
@Override
|
||||
|
@ -660,7 +660,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLivePlayViewHolder.setDrMicInfo(drPkbean);
|
||||
}
|
||||
}
|
||||
mLivePlayViewHolder.setDrPkView(drPkbeans);
|
||||
//mLivePlayViewHolder.setDrPkView(drPkbeans);
|
||||
}
|
||||
}else{//单人连麦
|
||||
LivePkMicModel connection_info = data.getEnterRoomInfo().getConnectionInfo();
|
||||
@ -723,7 +723,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
UserBean userBean = new UserBean();
|
||||
DrPkbean drPkbean = new DrPkbean();
|
||||
JSONObject da = array.getJSONObject(j);
|
||||
if(!String.valueOf(da.getIntValue("id")).equals(data.getLiveInfo().getUid())){
|
||||
if(!String.valueOf(da.getIntValue("id")).equals(String.valueOf(data.getLiveInfo().getUid()))){
|
||||
userBean.setId(String.valueOf(da.getIntValue("id")));
|
||||
drPkbean.setId(da.getIntValue("id"));
|
||||
drPkbean.setUser_nicename(da.getString("user_nicename"));
|
||||
@ -731,7 +731,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLivePlayViewHolder.setDrMicInfo(userBean);
|
||||
}
|
||||
}
|
||||
mLivePlayViewHolder.setDrPkView(drPkbeans);
|
||||
//mLivePlayViewHolder.setDrPkView(drPkbeans);
|
||||
}
|
||||
|
||||
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
|
||||
|
@ -69,7 +69,7 @@
|
||||
<LinearLayout
|
||||
android:id="@+id/dr_pk_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="290dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_marginTop="130dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone">
|
||||
|
Loading…
Reference in New Issue
Block a user