add[声望升级-游戏房判断声网或者融云]

This commit is contained in:
Martin 2024-05-20 16:18:16 +08:00
parent 0b218157d2
commit 3167ab0be8
16 changed files with 1432 additions and 72 deletions

View File

@ -210,25 +210,7 @@ public class AppContext extends CommonAppContext {
if (content.getContent().contains("_method_")) {
msg.obj = content.getContent();
//观众页面
if(SocketRyClient.mSocketHandler!=null){
if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
JSONObject map = received.getMsg().getJSONObject(0);
sendStartAnchorLive(map);
} else if (message.getTargetId().contains("v")) {
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
Bus.get().post(sudGameSocketImEvent);
}
//主播页面
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg);
}
}
if(SocketSwClient.mSocketHandler!=null){
if(CommonAppConfig.getInstance().getConfig().isSw()){
if (SocketSwClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketSwClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
@ -245,6 +227,23 @@ public class AppContext extends CommonAppContext {
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.sendMessage(msg);
}
}else{
if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
JSONObject map = received.getMsg().getJSONObject(0);
sendStartAnchorLive(map);
} else if (message.getTargetId().contains("v")) {
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
Bus.get().post(sudGameSocketImEvent);
}
//主播页面
if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg);
}
}
} else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息
EventBus.getDefault().post(message);

View File

@ -2,6 +2,7 @@ package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.utils.StringUtil;
import java.util.Arrays;
import java.util.List;
@ -59,6 +60,9 @@ public class ConfigBean extends BaseModel {
private String txPlayUgcLicenceUrl;//腾讯短视频鉴权
private String txVideoUgcKey;
private String google_isup;
@SerializedName("sud_game_speech")//0否1是
private String sudGameSpeech;
@SerializedName("is_return_user")//是否需要弹窗0否1是
private String isReturnUser="";
@SerializedName("popup_img_url")//弹窗图片地址
@ -182,6 +186,24 @@ public class ConfigBean extends BaseModel {
'}';
}
public boolean isSw(){
if(StringUtil.isEmpty(sudGameSpeech)){
return false;
}else if(sudGameSpeech.equals("1")){
return true;
}else{
return false;
}
}
public String getSudGameSpeech() {
return sudGameSpeech;
}
public void setSudGameSpeech(String sudGameSpeech) {
this.sudGameSpeech = sudGameSpeech;
}
@JSONField(name = "apk_ver")
public String getVersion() {
return version;

View File

@ -20,6 +20,7 @@ import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.enums.PopupPosition;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarChildModel;
@ -150,8 +151,6 @@ public class CreateSudGamePopup extends BottomPopupView {
.asCustom(new SudGameListSelectPopup(getContext(), 4, customSidebarChildModels, interactionID))
.show();
}
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.room_back),
@ -279,7 +278,11 @@ public class CreateSudGamePopup extends BottomPopupView {
public void onSuccess(CreateSudRoomModel data) {
if (isHome) {
dialog.dismiss();
RouteUtil.forwardSudGameActivity(new Gson().toJson(data),true,isHome);
if(CommonAppConfig.getInstance().getConfig().isSw()){
RouteUtil.forwardSwSudGameActivity(new Gson().toJson(data),true,isHome);
}else{
RouteUtil.forwardRySudGameActivity(new Gson().toJson(data),true,isHome);
}
} else {
Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(data));

View File

@ -0,0 +1,44 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.HttpCallbackModel;
public class SubGameEvent {
int type;
HttpCallbackModel model;
String dataJson;
public SubGameEvent(int type, HttpCallbackModel model, String dataJson) {
this.type = type;
this.model = model;
this.dataJson = dataJson;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public HttpCallbackModel getModel() {
return model;
}
public void setModel(HttpCallbackModel model) {
this.model = model;
}
public String getDataJson() {
return dataJson;
}
@Override
public String toString() {
return "SubGameEvent{" +
"type=" + type +
", model=" + model +
", dataJson='" + dataJson + '\'' +
'}';
}
}

View File

@ -0,0 +1,559 @@
package com.yunbao.common.manager.imrongcloud;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.SudGameChatImModel;
import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.event.SudGameSocketImEvent;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import java.util.ArrayList;
import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.RCRTCRoomConfig;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RCRTCParamsType;
import cn.rongcloud.rtc.base.RCRTCRoomType;
import cn.rongcloud.rtc.base.RTCErrorCode;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.chatroom.base.RongChatRoomClient;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
public class GameRyMicManager {
MeetingCallback mMeetingCallback = null;
private RCRTCRoom mRtcRoom = null;
private String mRoomID = "";
private final IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() {
/**
* 房间内用户发布资源
*
* @param rcrtcRemoteUser 远端用户
* @param list 发布的资源
*/
@Override
public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, final List<RCRTCInputStream> list) {
// subscribeAVStream();
}
@Override
public void onRemoteUserMuteAudio(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
}
@Override
public void onRemoteUserMuteVideo(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
}
@Override
public void onRemoteUserUnpublishResource(RCRTCRemoteUser rcrtcRemoteUser, List<RCRTCInputStream> list) {
}
/**
* 用户加入房间
*
* @param rcrtcRemoteUser 远端用户
*/
@Override
public void onUserJoined(final RCRTCRemoteUser rcrtcRemoteUser) {
try {
getView().onUserJoined(rcrtcRemoteUser);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
/**
* 用户离开房间
*
* @param rcrtcRemoteUser 远端用户
*/
@Override
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
try {
getView().onUserLeft(rcrtcRemoteUser);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onUserOffline(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void onPublishLiveStreams(List<RCRTCInputStream> list) {
}
@Override
public void onUnpublishLiveStreams(List<RCRTCInputStream> list) {
}
/**
* 自己退出房间 例如断网退出等
* @param i 状态码
*/
@Override
public void onLeaveRoom(int i) {
}
};
protected MeetingCallback getView() {
if (mMeetingCallback == null) {
throw new IllegalStateException("view is not attached");
} else {
return mMeetingCallback;
}
}
public void attachView(MeetingCallback callback) {
mMeetingCallback = callback;
}
public void detachView() {
mMeetingCallback = null;
}
/**
* 主动订阅远端用户发布的流
* 视频流需要用户设置用于显示载体的videoview
*/
public void subscribeAVStream() {
if (mRtcRoom == null || mRtcRoom.getRemoteUsers() == null) {
return;
}
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
for (final RCRTCRemoteUser remoteUser : mRtcRoom.getRemoteUsers()) {
if (remoteUser.getStreams().size() == 0) {
continue;
}
inputStreams.addAll(remoteUser.getStreams());
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(inputStreams);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void refreshStreams(List<SudGameUserModel> personList) {
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
for (SudGameUserModel sudGameUserModel : personList) {
List<RCRTCRemoteUser> rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(sudGameUserModel.getId()))) {
for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
rcrtcInputStream.mute(sudGameUserModel.getMicStatus() == 3);
}
inputStreams.addAll(rcrtcRemoteUser.getStreams());
}
}
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(inputStreams);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void refreshStreams(String userID, boolean mute, int position) {
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
List<RCRTCRemoteUser> rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(userID))) {
for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
rcrtcInputStream.mute(mute);
}
inputStreams.addAll(rcrtcRemoteUser.getStreams());
}
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(userID, mute, position);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onSubscribeFailed(userID);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
public void unPublishStreams() {
if (mRtcRoom == null) {
return;
}
mRtcRoom.getLocalUser().unpublishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onUnPublishStreamsSuccess();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
try {
getView().onUnPublishStreamsFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
/**
* 发布默认流
*/
public void publishDefaultAVStream() {
if (mRtcRoom == null) {
return;
}
mRtcRoom.getLocalUser().publishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onPublishSuccess();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
try {
getView().onPublishFailed();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
/**
* 配置rtc sdk
*/
public void config(Context context) {
// RCRTCConfig.Builder configBuilder = RCRTCConfig.Builder.create();
// // 是否硬解码
// configBuilder.enableHardwareDecoder(true);
// // 是否硬编码
// configBuilder.enableHardwareEncoder(true);
//
// // init 需结合 uninit 使用否则有些配置无法重新初始化
// RCRTCEngine.getInstance().unInit();
// RCRTCEngine.getInstance().init(context, configBuilder.build());
// RCRTCVideoStreamConfig.Builder videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create();
// // 设置分辨率
// videoConfigBuilder.setVideoResolution(RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280);
// // 设置帧率
// videoConfigBuilder.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_30);
// /**
// * 设置最小码率可根据分辨率RCRTCVideoResolution设置
// * {@link RCRTCParamsType.RCRTCVideoResolution)}
// */
// videoConfigBuilder.setMinRate(250);
// /**
// * 设置最大码率可根据分辨率RCRTCVideoResolution设置
// * {@link RCRTCParamsType.RCRTCVideoResolution)}
// */
// videoConfigBuilder.setMaxRate(2200);
// RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(videoConfigBuilder.build());
//打开扬声器
RCRTCEngine.getInstance().enableSpeaker(true);
// 启用耳返功能
RCRTCEngine.getInstance().getDefaultAudioStream().enableEarMonitoring(true);
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(false);
RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM);
}
public void joinRoom(String roomId, boolean imOff) {
mRoomID = roomId;
if (imOff) {
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
// 根据实际场景选择音视频直播LIVE_AUDIO_VIDEO 或音频直播LIVE_AUDIO
.setRoomType(RCRTCRoomType.MEETING)
.build();
RCRTCEngine.getInstance().joinRoom("v" + roomId, roomConfig, new IRCRTCResultDataCallback<RCRTCRoom>() {
@Override
public void onSuccess(final RCRTCRoom rcrtcRoom) {
GameRyMicManager.this.mRtcRoom = rcrtcRoom;
// 注册房间回调
rcrtcRoom.registerRoomListener(roomEventsListener);
try {
getView().onJoinRoomSuccess(rcrtcRoom);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
try {
getView().onJoinRoomFailed(rtcErrorCode);
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
});
}
RongChatRoomClient.getInstance().joinChatRoom("v" + roomId, -1, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
Log.i("tx", "加入成功");
enterRoom();
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
Log.i("tx", "加入" + "失败" + coreErrorCode);
if (WordUtil.isNewZh()) {
ToastUtil.show("網絡不佳無法連接,請重新進入");
} else {
ToastUtil.show("The network is not connected, please re-enter");
}
}
});
}
public void leaveRoom() {
RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode rtcErrorCode) {
}
@Override
public void onSuccess() {
}
});
RongChatRoomClient.getInstance().quitChatRoom("v" + mRoomID, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
Log.i("tx", "退出成功");
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
Log.i("tx", "退出" + "" + coreErrorCode);
}
});
}
/**
* 处理游戏房Im消息
*/
public void processingMessage(SudGameSocketImEvent socketImModel) {
List<SudGameSocketImEvent.MsgDTO> msgDTOS = socketImModel.getMsg();
if (msgDTOS.isEmpty()) return;
SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0);
//正常文字消息
if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) {
getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt()));
} else if (TextUtils.equals(msgDTO.getMethod(), "welcomMessage")) {
// 欢迎用户名进入房间 Welcome (username) to the room
StringBuffer stringBuffer = new StringBuffer();
if (WordUtil.isNewZh()) {
stringBuffer.append("歡迎 ").append(msgDTO.getCt()).append(" 進入房間");
} else {
stringBuffer.append("Welcome ").append(msgDTO.getCt()).append(" to enter the room");
}
getView().insertItem(new SudGameChatImModel().setWelcomMessage(true).setNickname(msgDTO.getCt()).setTextMessage(stringBuffer.toString()));
} else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) {
List<SudGameUserModel> personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken<List<SudGameUserModel>>() {
}.getType());
getView().refreshSudGameUserList(personList);
refreshStreams(personList);
}
}
private void sendChatMessage(String textMessage, String method) {
IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent();
sudGameSocketImEvent.setRetcode("000000");
sudGameSocketImEvent.setRetmsg("ok");
SudGameSocketImEvent.MsgDTO msgDTO = new SudGameSocketImEvent.MsgDTO();
msgDTO.setAction("0")
.setCt(textMessage)
.setEquipment("app")
.setUid(String.valueOf(loginModel.getId()))
.setMethod(method)
.setUname(loginModel.getUserNicename())
.setRoomnum(mRoomID);
List<SudGameSocketImEvent.MsgDTO> msgDTOS = new ArrayList<>();
msgDTOS.add(msgDTO);
sudGameSocketImEvent.setMsg(msgDTOS);
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(new Gson().toJson(sudGameSocketImEvent));
Message message = Message.obtain("v" + mRoomID, conversationType, messageContent);
RongcloudIMManager.sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override
public void onAttached(Message message) {
}
@Override
public void onSuccess(Message message) {
Log.i("tx", "发送成功");
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
processingMessage(sudGameSocketImEvent);
}
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
Log.i("tx", "发送成功" + errorCode.toString());
}
});
}
/**
* 发送聊天信息
*
* @param textMessage
*/
public void sendMessage(String textMessage) {
sendChatMessage(textMessage, "SendMsg");
}
/**
* 进房间
*/
public void enterRoom() {
IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
sendChatMessage(loginModel.getUserNicename(), "welcomMessage");
}
/**
* activity相关回调
*/
public interface MeetingCallback {
void onJoinRoomSuccess(RCRTCRoom rcrtcRoom);
void onJoinRoomFailed(RTCErrorCode rtcErrorCode);
void onPublishSuccess();
void onPublishFailed();
void onUnPublishStreamsSuccess();
void onUnPublishStreamsFailed();
void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList);
void onSubscribeFailed();
void onSubscribeSuccess(String userID, boolean mute, int position);
void onSubscribeFailed(String userID);
void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser);
void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser);
void insertItem(SudGameChatImModel sudGameChatImModel);
void refreshSudGameUserList(List<SudGameUserModel> personList);
}
}

View File

@ -38,7 +38,7 @@ import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
public class GameMicManager {
public class GameSwMicManager {
MeetingCallback mMeetingCallback = null;
private RCRTCRoom mRtcRoom = null;
private String mRoomID = "";
@ -369,7 +369,7 @@ public class GameMicManager {
RCRTCEngine.getInstance().joinRoom("v" + roomId, roomConfig, new IRCRTCResultDataCallback<RCRTCRoom>() {
@Override
public void onSuccess(final RCRTCRoom rcrtcRoom) {
GameMicManager.this.mRtcRoom = rcrtcRoom;
GameSwMicManager.this.mRtcRoom = rcrtcRoom;
// 注册房间回调
rcrtcRoom.registerRoomListener(roomEventsListener);
try {

View File

@ -48,7 +48,8 @@ public class RouteUtil {
public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity";
public static final String PATH_SELECT_AVATAR = "/main/UserAvatarSelectActivity";
public static final String PATH_BattlePassActivity = "/main/BattlePassActivity";
public static final String PATH_SudGameActivity = "/live/SudGameActivity";
public static final String PATH_SudSwGameActivity = "/live/SudSwGameActivity";
public static final String PATH_SudRyGameActivity = "/live/SudRyGameActivity";
public static final String PATH_COMMUNITY_Activity = "/main/MainHomeCommunityActivity";
@ -64,8 +65,16 @@ public class RouteUtil {
.navigation();
}
public static void forwardSudGameActivity(String CreateSudRoom, boolean isAn, boolean isHome) {
ARouter.getInstance().build(PATH_SudGameActivity)
public static void forwardSwSudGameActivity(String CreateSudRoom, boolean isAn, boolean isHome) {
ARouter.getInstance().build(PATH_SudSwGameActivity)
.withString("CreateSudRoom", CreateSudRoom)
.withBoolean("CreateIsAn", isAn)
.withBoolean("CreateIsHome", isHome)
.navigation();
}
public static void forwardRySudGameActivity(String CreateSudRoom, boolean isAn, boolean isHome) {
ARouter.getInstance().build(PATH_SudRyGameActivity)
.withString("CreateSudRoom", CreateSudRoom)
.withBoolean("CreateIsAn", isAn)
.withBoolean("CreateIsHome", isHome)

View File

@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.LiveBean;
@ -106,8 +107,11 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
createSudRoomModel.setSudGameName(model.getSudGameName());
if (isHome) {
if (TextUtils.equals(model.getLiveUid(), "0")) {
RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel),false,isHome);
if(CommonAppConfig.getInstance().getConfig().isSw()){
RouteUtil.forwardSwSudGameActivity(new Gson().toJson(data),true,isHome);
}else{
RouteUtil.forwardRySudGameActivity(new Gson().toJson(data),true,isHome);
}
} else {
String yes = "";
if (IMLoginManager.get(itemView.getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
@ -155,8 +159,11 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
@Override
public void onCancel() {
RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel),false,isHome);
if(CommonAppConfig.getInstance().getConfig().isSw()){
RouteUtil.forwardSwSudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome);
}else{
RouteUtil.forwardRySudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome);
}
}
})).show();

View File

@ -85,7 +85,10 @@
android:name=".activity.WebViewActivityMedal"
android:screenOrientation="portrait" />
<activity
android:name=".activity.SudGameActivity"
android:name=".activity.SudSwGameActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.SudRyGameActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.MedalQuestionWebViewActivity"

View File

@ -1798,7 +1798,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}else{
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
}
}
/**

View File

@ -0,0 +1,698 @@
package com.yunbao.live.activity;
import android.Manifest;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.adapter.SudGameChatAdapter;
import com.yunbao.common.adapter.SudGameUserListAdapter;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarChildModel;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.RoomMicStatusModel;
import com.yunbao.common.bean.SudGameChatImModel;
import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.dialog.SudGameInputPopupWindow;
import com.yunbao.common.event.CheckRemainingBalanceEvent;
import com.yunbao.common.event.SubGameEvent;
import com.yunbao.common.event.SudGameSocketImEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.GameRyMicManager;
import com.yunbao.common.sud.QuickStartGameViewModel;
import com.yunbao.common.sud.model.GameConfigModel;
import com.yunbao.common.sud.model.GameViewInfoModel;
import com.yunbao.common.sud.state.SudMGPAPPState;
import com.yunbao.common.sud.state.SudMGPMGState;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.LiveSudGameHistoryPopup;
import com.yunbao.common.views.TopGradual;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.dialog.LiveUserDialogFragment;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RTCErrorCode;
@Route(path = RouteUtil.PATH_SudRyGameActivity)
public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.MeetingCallback {
private FrameLayout gameContainer;
private long mInteractionID;
private String mLiveUid;
private final QuickStartGameViewModel gameViewModel = new QuickStartGameViewModel(); // 创建ViewModel
private CreateSudRoomModel mCreateSudRoomModel;
private TextView roomName, roomNumber;
private GameRyMicManager gameMicManager;
private ImageView gameCloseWheat, gameSeat;
private boolean disable = true, publishDefault = false;
private RecyclerView chatList, userList;
private SudGameChatAdapter mLiveChatAdapter;
private SudGameUserListAdapter sudGameUserListAdapter;
private ProcessResultUtil mProcessResultUtil;
private List<String> muteUser = new ArrayList<>();
private boolean imOff;
@Override
protected int getLayoutId() {
return R.layout.activity_sud_game;
}
@Override
protected void main() {
Bus.getOn(this);
super.main();
initView();
initDate();
}
private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>();
private void initDate() {
LiveNetManager.get(mContext)
.getCustomSidebarInfo("1", new HttpCallback<List<CustomSidebarInfoModel>>() {
@Override
public void onSuccess(List<CustomSidebarInfoModel> data) {
for (CustomSidebarInfoModel datum : data) {
if (datum.getType().equals("6")) {
customSidebarChildModels = datum.getChild();
return;
}
}
}
@Override
public void onError(String error) {
}
});
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
gameCloseWheat.setVisibility(View.INVISIBLE);
mProcessResultUtil = new ProcessResultUtil(this);
LiveNetManager.get(mContext)
.getRoomMicStatus(new HttpCallback<RoomMicStatusModel>() {
@Override
public void onSuccess(RoomMicStatusModel data) {
gameMicManager = new GameRyMicManager();
gameMicManager.attachView(SudRyGameActivity.this);
gameMicManager.config(SudRyGameActivity.this);
//语音
if (TextUtils.equals(data.getMicStatus(), "1")) {
imOff = true;
gameSeat.setVisibility(View.VISIBLE);
userList.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
ToastUtil.show("拒绝权限将无法使用上麦功能");
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@Override
public void run() {
}
});
}
}
}, 1500);
} else {
imOff = false;
gameSeat.setVisibility(View.GONE);
userList.setVisibility(View.GONE);
}
if (TextUtils.equals(data.getImStatus(), "1")) {
findViewById(R.id.game_review_input).setVisibility(View.VISIBLE);
chatList.setVisibility(View.VISIBLE);
} else {
findViewById(R.id.game_review_input).setVisibility(View.GONE);
chatList.setVisibility(View.GONE);
}
gameMicManager.joinRoom(mLiveUid, imOff);
}
@Override
public void onError(String error) {
imOff = false;
//文字
findViewById(R.id.game_review_input).setVisibility(View.GONE);
chatList.setVisibility(View.GONE);
//语音
gameCloseWheat.setVisibility(View.GONE);
gameSeat.setVisibility(View.GONE);
userList.setVisibility(View.GONE);
}
});
}
@Override
protected void onDestroy() {
LiveNetManager.get(mContext)
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
if (gameMicManager != null) {
gameMicManager.leaveRoom();
gameMicManager.detachView();
}
Bus.getOff(this);
super.onDestroy();
}
private void initView() {
String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom");
mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class);
mInteractionID = mCreateSudRoomModel.getLongSudGameId();
mLiveUid = mCreateSudRoomModel.getSudGameRoomId();
gameContainer = findViewById(R.id.game_container);
roomName = findViewById(R.id.room_name);
roomNumber = findViewById(R.id.room_number);
gameCloseWheat = findViewById(R.id.game_close_wheat);
gameSeat = findViewById(R.id.game_seat);
chatList = findViewById(R.id.chat_list);
userList = findViewById(R.id.user_list);
//聊天栏
FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams)
chatList.getLayoutParams();
params1.topMargin = DpUtil.dp2px(65);
chatList.setLayoutParams(params1);
chatList.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setOrientation(RecyclerView.VERTICAL);
layoutManager.setStackFromEnd(true);
chatList.setLayoutManager(layoutManager);
chatList.addItemDecoration(new TopGradual());
chatList.setItemViewCacheSize(10);
mLiveChatAdapter = new SudGameChatAdapter(mContext);
chatList.setAdapter(mLiveChatAdapter);
sudGameUserListAdapter = new SudGameUserListAdapter(new ArrayList<>());
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
sudGameUserListAdapter.setSudGameSmallCallBack(new SudGameUserListAdapter.SudGameSmallCallBack() {
@Override
public void unMute(String userID, int position) {
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
gameMicManager.refreshStreams(userID, false, position);
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
muteUser.remove(userID);
}
@Override
public void mute(String userID, int position) {
muteUser.add(userID);
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
gameMicManager.refreshStreams(userID, true, position);
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
}
@Override
public void viewInformation(SudGameUserModel sudGameUserModel) {
LiveUserDialogFragment fragment = new LiveUserDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.LIVE_UID, "uid");
bundle.putString(Constants.STREAM, "");
bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + "");
fragment.setArguments(bundle);
fragment.show(((SudRyGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
}
});
userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
userList.setAdapter(sudGameUserListAdapter);
if (mCreateSudRoomModel != null) {
roomName.setText(mCreateSudRoomModel.getRoomName());
roomNumber.setText(mCreateSudRoomModel.getSudGameRoomId());
}
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exit), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
gameViewModel.onDestroy();
finish();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
new XPopup.Builder(mContext)
.enableDrag(false)
.asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (imOff && gameMicManager != null) {
if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
if (publishDefault) {
disable = true;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
// ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
gameMicManager.unPublishStreams();
} else {
if (sudGameUserListAdapter.isMicMax()) {
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
} else {
gameMicManager.publishDefaultAVStream();
}
}
} else {
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@Override
public void run() {
}
});
}
}
}
});
ViewClicksAntiShake.clicksAntiShake(gameCloseWheat, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (imOff && gameMicManager != null) {
gameCloseWheat.post(new Runnable() {
@Override
public void run() {
if (disable) {
disable = false;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
LiveNetManager.get(mContext)
.onMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on");
} else {
disable = true;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
LiveNetManager.get(mContext)
.offMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off");
}
}
});
}
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_review_input), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
new XPopup.Builder(mContext)
.enableDrag(false)
.asCustom(new SudGameInputPopupWindow(mContext, new SudGameInputPopupWindow.SudGameInputCallBack() {
@Override
public void sendMessage(String textMessage) {
gameMicManager.sendMessage(textMessage);
}
}))
.show();
}
});
gameViewModel.gameViewLiveData.observe(this, new Observer<View>() {
@Override
public void onChanged(View view) {
if (view == null) { // 在关闭游戏时把游戏View给移除
gameContainer.removeAllViews();
} else { // 把游戏View添加到容器内
gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
}
}
});
// 加载游戏参数定义可查看BaseGameViewModel.switchGame()方法注释
// 游戏配置
GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel();
gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.lobby_players.custom = true;
gameConfigModel.ui.join_btn.custom = true;
gameConfigModel.ui.game_settle_again_btn.custom = true;
gameConfigModel.ui.start_btn.custom = true;
// SudMGP平台64bit游戏ID
gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID);
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, -1, true, 1);
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfCaptain(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
// ViewClicksAntiShake.clicksAntiShake(gameTitle, new ViewClicksAntiShake.ViewClicksCallBack() {
// @Override
// public void onViewClicks() {
//
// }
// });
// 设置游戏安全操作区域
GameViewInfoModel.GameViewRectModel gameViewRectModel = new GameViewInfoModel.GameViewRectModel();
gameViewRectModel.left = 0;
gameViewRectModel.top = DpUtil.dp2px(155);
gameViewRectModel.right = 0;
gameViewRectModel.bottom = DpUtil.dp2px(155);
gameViewModel.gameViewRectModel = gameViewRectModel;
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) {
switch (event.getSudMGPMGState()) {
case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN:
case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN:
LiveNetManager.get(mContext).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<CheckRemainingBalance>() {
@Override
public void onSuccess(CheckRemainingBalance data) {
if (TextUtils.equals(String.valueOf(data.getGoldenBeanRemainingBalance()), "1")) {
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1);
} else {
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("貨幣数量不足 ");
} else {
ToastUtil.show("Insufficient number of currency");
}
}
// ToastUtil.show(data.toString());
}
@Override
public void onError(String error) {
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("貨幣数量不足 ");
} else {
ToastUtil.show("Insufficient number of currency");
}
}
});
break;
case SudMGPMGState.MG_COMMON_GAME_SETTLE:
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1);
break;
case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN:
LiveNetManager.get(mContext).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(),
mCreateSudRoomModel.getSudGameRoomId(), new
HttpCallback<CheckRemainingBalance>() {
@Override
public void onSuccess(CheckRemainingBalance data) {
if (data.getStatus() == 1) {
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfPlaying(true);
} else {
}
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
break;
case SudMGPMGState.MG_COMMON_GAME_STATE:
LiveNetManager.get(mContext).deductMoney(mCreateSudRoomModel.getSudGameRoomId());
break;
}
}
@Override
public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) {
LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback<List<SudGameUserModel>>() {
@Override
public void onSuccess(List<SudGameUserModel> data) {
gameMicManager.refreshStreams(data);
sudGameUserListAdapter.refreshSudGameUserList(data, muteUser);
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
// 主动订阅远端用户发布的资源
// gameMicManager.subscribeAVStream();
}
@Override
public void onJoinRoomFailed(RTCErrorCode rtcErrorCode) {
ToastUtil.show("加入失败 " + rtcErrorCode.toString());
}
@Override
public void onPublishSuccess() {
runOnUiThread(new Runnable() {
@Override
public void run() {
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_hang_up : R.mipmap.icon_game_hang_up_en, gameSeat);
publishDefault = true;
gameCloseWheat.setVisibility(View.VISIBLE);
disable = false;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
}
});
LiveNetManager.get(mContext)
.joinMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
}
@Override
public void onPublishFailed() {
ToastUtil.show(WordUtil.isNewZh() ? "語音加入失敗" : "Voice joining failed");
}
@Override
public void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList) {
// ToastUtil.show("订阅成功 ");
}
@Override
public void onSubscribeFailed() {
ToastUtil.show("订阅失败 ");
}
@Override
public void onSubscribeSuccess(String userID, boolean mute, int position) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mute) {
ToastUtil.show(WordUtil.isNewZh() ? "已靜音該用戶" : "The user has been muted");
} else {
ToastUtil.show(WordUtil.isNewZh() ? "已取消該用戶靜音" : "The user has been unmuted");
}
sudGameUserListAdapter.muteUser(userID, mute, position);
}
});
}
@Override
public void onSubscribeFailed(String userID) {
ToastUtil.show("订阅失败 ");
}
@Override
public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
}
@Override
public void insertItem(SudGameChatImModel sudGameChatImModel) {
mLiveChatAdapter.insertItem(sudGameChatImModel);
}
@Override
public void refreshSudGameUserList(List<SudGameUserModel> personList) {
sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser);
}
@Override
public void onUnPublishStreamsSuccess() {
runOnUiThread(new Runnable() {
@Override
public void run() {
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
publishDefault = false;
gameCloseWheat.setVisibility(View.INVISIBLE);
}
});
LiveNetManager.get(mContext)
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
@Override
public void onError(String error) {
}
});
}
@Override
public void onUnPublishStreamsFailed() {
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameSocketImEvent(SudGameSocketImEvent event) {
gameMicManager.processingMessage(event);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameUserModel(SudGameUserModel model) {
if (model.isNullUser()) {
if (!publishDefault) {
if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
if (sudGameUserListAdapter.isMicMax()) {
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
} else {
gameMicManager.publishDefaultAVStream();
}
} else {
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@Override
public void run() {
}
});
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "已經是上麥狀態" : "It is already in the wheat state");
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameStatus(SubGameEvent event) {
if (event.getType() == 0) {
Log.i("游戏回调", "onGameStateChange: event :" + event.toString());
if (event.getModel().getCode() == 1001 || event.getModel().getCode() == 1002) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("result", 0);
gameViewModel.sudFSTAPPDecorator.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_CREATE_ORDER_RESULT, jsonObject.toString());
}
}
}
}

View File

@ -39,7 +39,7 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.GameMicManager;
import com.yunbao.common.manager.imrongcloud.GameSwMicManager;
import com.yunbao.common.sud.QuickStartGameViewModel;
import com.yunbao.common.sud.model.GameConfigModel;
import com.yunbao.common.sud.model.GameViewInfoModel;
@ -72,8 +72,8 @@ import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.chatroom.base.RongChatRoomClient;
@Route(path = RouteUtil.PATH_SudGameActivity)
public class SudGameActivity extends AbsActivity implements GameMicManager.MeetingCallback {
@Route(path = RouteUtil.PATH_SudSwGameActivity)
public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.MeetingCallback {
private FrameLayout gameContainer;
private long mInteractionID;
private String mLiveUid;
@ -81,7 +81,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
private CreateSudRoomModel mCreateSudRoomModel;
private TextView roomName, roomNumber;
private GameMicManager gameMicManager;
private GameSwMicManager gameMicManager;
private ImageView gameCloseWheat, gameSeat;
private boolean disable = true, publishDefault = false;
@ -91,7 +91,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
private ProcessResultUtil mProcessResultUtil;
private List<String> muteUser = new ArrayList<>();
private boolean imOff;
private boolean isSw = true;
private boolean isSw = CommonAppConfig.getInstance().getConfig().isSw();
@Override
protected int getLayoutId() {
@ -136,9 +136,9 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
LiveNetManager.get(mContext).getRoomMicStatus(new HttpCallback<RoomMicStatusModel>() {
@Override
public void onSuccess(RoomMicStatusModel data) {
gameMicManager = new GameMicManager();
gameMicManager.attachView(SudGameActivity.this);
gameMicManager.config(SudGameActivity.this);
gameMicManager = new GameSwMicManager();
gameMicManager.attachView(SudSwGameActivity.this);
gameMicManager.config(SudSwGameActivity.this);
//初始化声网引擎
SWAuManager.get().initRtcEngineAudio(mContext);
//语音
@ -316,7 +316,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
bundle.putString(Constants.STREAM, "");
bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + "");
fragment.setArguments(bundle);
fragment.show(((SudGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
fragment.show(((SudSwGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
}
});
userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));

View File

@ -231,14 +231,12 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
goHomeUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mContext instanceof LiveAnchorActivity) {
((LiveAnchorActivity) mContext).superBackPressed();
if (mContext instanceof LiveRyAnchorActivity) {
((LiveRyAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {
((LiveSwAnchorActivity) mContext).superBackPressed();
}else if(mContext instanceof LiveRyAnchorActivity){
((LiveRyAnchorActivity) mContext).superBackPressed();
}
Bus.get().post(new CloseEvent());
}
@ -264,8 +262,8 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mContext instanceof LiveAnchorActivity) {
((LiveAnchorActivity) mContext).superBackPressed();
if (mContext instanceof LiveRyAnchorActivity) {
((LiveRyAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
} else if (mContext instanceof LiveSwAnchorActivity) {

View File

@ -3685,35 +3685,37 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (isStayRoomfive) {
showFollowDialog(mNameText, mAvatarUrl, mContext);
} else {
if(mContext instanceof LiveSwAnchorActivity){
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}
} else {
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}
} else {
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
}
}else if(mContext instanceof LiveRyAnchorActivity){
if (forAct == 1) {
//是否关注0==没关注
if (isAttention == 0) {
if (isStayRoomfive) {
showFollowDialog(mNameText, mAvatarUrl, mContext);
} else {
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
}
} else {
if(mContext instanceof LiveSwAnchorActivity){
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
} else {
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
}
} else {
if(mContext instanceof LiveSwAnchorActivity){
LiveSwAnchorActivity.backIndex = 1;
((LiveSwAnchorActivity) mContext).onBackPressed();
} else {
LiveRyAnchorActivity.backIndex = 1;
((LiveRyAnchorActivity) mContext).onBackPressed();
}
}
}
}
/**
* 在直播间时间是否足够5分钟

View File

@ -1,5 +1,6 @@
package com.yunbao.live.views;
import static com.yunbao.live.activity.LiveActivity.isSw;
import static com.yunbao.live.activity.LiveActivity.mLiveUid;
import static com.yunbao.live.activity.LiveSwAnchorActivity.PKing;
import static com.yunbao.live.activity.LiveSwAnchorActivity.pk_nub;
@ -174,7 +175,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (yaoqing.size() < 3) {
if (PKing == false) {
if(isSw){
((LiveSwAnchorActivity) mContext).openLinkMicAnchorWindow(true);
}else{
((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
}
@ -242,8 +247,12 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
* 关闭直播
*/
private void close() {
if(isSw){
((LiveSwAnchorActivity) mContext).closeLive();
}else{
((LiveRyAnchorActivity) mContext).closeLive();
}
}
@Override
public void onDestroy() {
@ -258,8 +267,12 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (mBtnFunction != null) {
mBtnFunction.setImageDrawable(mDrawable1);
}
if(isSw){
((LiveSwAnchorActivity) mContext).showFunctionDialog();
}else{
((LiveRyAnchorActivity) mContext).showFunctionDialog();
}
}
/**
* 设置功能按钮变暗
@ -291,8 +304,12 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
* 发起主播连麦pk
*/
private void applyLinkMicPk() {
if(isSw){
((LiveSwAnchorActivity) mContext).applyLinkMicPk();
}else{
((LiveRyAnchorActivity) mContext).applyLinkMicPk();
}
}
public void setLinkMicEnable(boolean linkMicEnable) {
mLinkMicEnable = linkMicEnable;

View File

@ -17,7 +17,7 @@ import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupPosition;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.live.activity.SudGameActivity;
import com.yunbao.live.activity.SudSwGameActivity;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.adapter.SudGameListAdapter;
import com.yunbao.common.bean.CreateSudRoomModel;
@ -158,7 +158,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
@Override
public void onSuccess(CreateSudRoomModel data) {
if (data != null) {
Intent intent = new Intent(context, SudGameActivity.class);
Intent intent = new Intent(context, SudSwGameActivity.class);
intent.putExtra("CreateSudRoom", new Gson().toJson(data));
context.startActivity(intent);
} else {