add[声望升级-小游戏多人连麦]

This commit is contained in:
Martin 2024-05-09 16:01:39 +08:00
parent 95ded2f77c
commit abfd15f751
10 changed files with 353 additions and 211 deletions

View File

@ -279,7 +279,7 @@ public class CreateSudGamePopup extends BottomPopupView {
public void onSuccess(CreateSudRoomModel data) {
if (isHome) {
dialog.dismiss();
RouteUtil.forwardSudGameActivity(new Gson().toJson(data));
RouteUtil.forwardSudGameActivity(new Gson().toJson(data),true,isHome);
} else {
Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(data));

View File

@ -43,6 +43,9 @@ public class GameMicManager {
private RCRTCRoom mRtcRoom = null;
private String mRoomID = "";
public void setmRoomID(String mRoomID) {
this.mRoomID = mRoomID;
}
private final IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() {
/**
@ -183,43 +186,44 @@ public class GameMicManager {
public void refreshStreams(List<SudGameUserModel> personList) {
final List<RCRTCInputStream> inputStreams = new ArrayList<>();
if(mRtcRoom!=null){
for (SudGameUserModel sudGameUserModel : personList) {
List<RCRTCRemoteUser> rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
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);
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());
}
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();
}
}
});
}
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) {
@ -242,8 +246,6 @@ public class GameMicManager {
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
try {
getView().onSubscribeSuccess(userID, mute, position);
} catch (IllegalStateException e) {

View File

@ -49,6 +49,7 @@ public class RouteUtil {
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_COMMUNITY_Activity="/main/MainHomeCommunityActivity";
@ -61,9 +62,11 @@ public class RouteUtil {
.withString(Constants.TO_UID, uid)
.navigation();
}
public static void forwardSudGameActivity(String CreateSudRoom) {
public static void forwardSudGameActivity(String CreateSudRoom,boolean isAn,boolean isHome) {
ARouter.getInstance().build(PATH_SudGameActivity)
.withString("CreateSudRoom", CreateSudRoom)
.withBoolean("CreateIsAn", isAn)
.withBoolean("CreateIsHome", isHome)
.navigation();
}

View File

@ -106,7 +106,7 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
createSudRoomModel.setSudGameName(model.getSudGameName());
if (isHome) {
if (TextUtils.equals(model.getLiveUid(), "0")) {
RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel));
RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel),false,isHome);
} else {
String yes = "";
@ -156,7 +156,7 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
@Override
public void onCancel() {
RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel));
RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel),false,isHome);
}
})).show();

View File

@ -53,6 +53,20 @@ public class SWAuManager extends BaseCacheManager {
return manager;
}
IRtcEngineEventHandler mEventHandler = new IRtcEngineEventHandler() {
@Override
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
super.onJoinChannelSuccess(channel, uid, elapsed);
L.eSw("加入房间成功 channel"+channel+" uid"+uid);
}
@Override
public void onUserJoined(int uid, int elapsed) {
super.onUserJoined(uid, elapsed);
L.eSw("用户加入房间成功"+uid);
}
};
/**
* 初始化声网SDK
*/
@ -76,11 +90,52 @@ public class SWAuManager extends BaseCacheManager {
//mRtcEngine.startPreview();
}
/**
* 初始化声网SDK-语音房
*/
public void initRtcEngineAudio(Activity mContext) {
this.mContext = mContext;
try {
// 创建 RtcEngineConfig 对象并进行配置
RtcEngineConfig config = new RtcEngineConfig();
config.mContext = mContext;
config.mAppId = SWAuManager.shengwang_appId;
config.mEventHandler = mEventHandler;
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
mRtcEngine.enableAudio();
mRtcEngine.enableLocalAudio(true);
} catch (Exception e) {
throw new RuntimeException("Check the error.");
}
}
/**
* 创建语音房
* @param token
* @param channelName
* @param uid
*/
public void joinAudioRoom(String channelName,String token,int uid){
L.eSw("加入房间"+channelName+" uid"+uid);
// 创建 ChannelMediaOptions 对象并进行配置
ChannelMediaOptions options = new ChannelMediaOptions();
// 根据场景将用户角色设置为 AUDIENCE (观众)
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
// 直播场景下设置频道场景为 BROADCASTING (直播场景)
options.audienceLatencyLevel = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING; // 觀眾走極速直播
options.autoSubscribeVideo = false;
options.autoSubscribeAudio = true;
mRtcEngine.joinChannel(token, channelName, uid, options);
}
/**
* 更新主播视图
*
* @param frameLayout
*/
public void updateMyChannelView(FrameLayout frameLayout,int uid) {
public void updateMyChannelView(FrameLayout frameLayout, int uid) {
mRtcEngine.setupLocalVideo(null);
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
@ -114,7 +169,6 @@ public class SWAuManager extends BaseCacheManager {
mRtcEngine.joinChannel(token, channelName, uid, options);
}
public void joinExRoomEx(int strUid, String token, String channelName) {
// 创建 ChannelMediaOptions 对象并进行配置
ChannelMediaOptions options = new ChannelMediaOptions();
@ -136,7 +190,7 @@ public class SWAuManager extends BaseCacheManager {
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
L.eSw("onJoinChannelSuccess:" + channel + " uid " +uid+ " elapsed: " + elapsed);
L.eSw("onJoinChannelSuccess:" + channel + " uid " + uid + " elapsed: " + elapsed);
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
pkContainer1.addView(surfaceView);
@ -156,32 +210,38 @@ public class SWAuManager extends BaseCacheManager {
/**
* 与主播连麦
*
* @param isUp true 上麦 false 下麦
*/
public void setMicAn(boolean isUp) {
L.eSw("setMicAn-isUp:"+isUp);
ChannelMediaOptions options = new ChannelMediaOptions();
if(isUp){
L.eSw("setMicAn-isUp:" + isUp);
ChannelMediaOptions options = new ChannelMediaOptions();
if (isUp) {
options.publishCameraTrack = false; //控制是否发视频
options.publishMicrophoneTrack = true; //控制是否发音频
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; //设置身份为主播
}else{
} else {
options.publishCameraTrack = false; //控制是否发视频
options.publishMicrophoneTrack = false; //控制是否发音频
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE; //设置身份为观众
options.audienceLatencyLevel=Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY ;//设置为极速直播观众
options.audienceLatencyLevel = Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY;//设置为极速直播观众
}
mRtcEngine.updateChannelMediaOptions(options);
}
public void setMicAudio(int toUid,boolean isEn) {
L.eSw("setMicAudio:toUid" +toUid+"isEn "+ isEn);
mRtcEngine.muteRemoteAudioStream(toUid,isEn);
}
/**
* PK-加入对方主播直播间
*
* @param strUid
* @param token
* @param toUid
* @param channelName
*/
public void joinChannelDrEx(FrameLayout frameLayout,String strUid, String token, String toUid, String channelName) {
public void joinChannelDrEx(FrameLayout frameLayout, String strUid, String token, String toUid, String channelName) {
int tempUid;
if (StringUtil.isEmpty(strUid)) {
tempUid = 0;
@ -213,7 +273,7 @@ public class SWAuManager extends BaseCacheManager {
SurfaceView surfaceView = new SurfaceView(mContext);
surfaceView.setZOrderMediaOverlay(true);
frameLayout.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN,Integer.parseInt(toUid));
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid));
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
}
});
@ -234,10 +294,11 @@ public class SWAuManager extends BaseCacheManager {
/**
* 退出对方直播间
* @param uid 自己的ID
*
* @param uid 自己的ID
* @param liveUid 对方直播间号
*/
public void exitChannelToUid(int uid, String liveUid){
public void exitChannelToUid(int uid, String liveUid) {
RtcConnection rtcConnection = new RtcConnection();
rtcConnection.channelId = getChannelName(liveUid); //對方主播的頻道
rtcConnection.localUid = uid;//自己的ID
@ -247,14 +308,14 @@ public class SWAuManager extends BaseCacheManager {
/**
* 退出所有的直播间
*/
public void exitChannelAll(){
public void exitChannelAll() {
mRtcEngine.leaveChannel();
}
public static String getChannelName(String liveUid) {
if(liveUid.contains("g")){
if (liveUid.contains("g")) {
return liveUid;
}else{
} else {
return CommonAppConfig.SWChannelPrefix + liveUid;
}
}

View File

@ -126,6 +126,7 @@ import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
import com.yunbao.live.dialog.SignDialogFragment;
import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveOpenSuccessEvent;
import com.yunbao.live.http.ImHttpUtil;
import com.yunbao.live.views.LiveRoomPlayViewHolder;
import com.yunbao.live.views.LiveRoomViewHolder;
@ -746,6 +747,14 @@ public class LiveAudienceActivity extends LiveActivity {
manager.onLinkMicTxAccEvent(e);
}
/**
* 腾讯sdk连麦时候切换低延时流
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLinkMicTxAccEvent(LiveOpenSuccessEvent e) {
manager.loadTimeoutRunnableGone();
}
/**
* 腾讯sdk时候主播连麦回调
*
@ -1072,6 +1081,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (manager != null && manager.getsudGameMin()) {
ToastUtil.show(WordUtil.isNewZh() ? "您已在游戏房间中" : "You are already in the game room");
} else {
//直播间来的
new XPopup.Builder(mContext)
.enableDrag(false)
// .dismissOnTouchOutside(false)
@ -1874,6 +1884,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (manager != null && manager.getsudGameMin()) {
ToastUtil.show(WordUtil.isNewZh() ? "您已在游戏房间中" : "You are already in the game room");
} else {
//直播间来的
new XPopup.Builder(mContext)
.enableDrag(false)
// .dismissOnTouchOutside(false)

View File

@ -5,6 +5,7 @@ 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;
@ -17,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.activity.AbsActivity;
@ -65,6 +67,10 @@ 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;
import io.agora.beautyapi.faceunity.agora.SWAuManager;
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 {
@ -85,6 +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;
@Override
protected int getLayoutId() {
@ -103,108 +110,136 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
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;
}
}
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) {
@Override
public void onError(String error) {
}
});
}
});
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
//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 GameMicManager();
gameMicManager.attachView(SudGameActivity.this);
gameMicManager.config(SudGameActivity.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() {
LiveNetManager.get(mContext).getRoomMicStatus(new HttpCallback<RoomMicStatusModel>() {
@Override
public void onSuccess(RoomMicStatusModel data) {
gameMicManager = new GameMicManager();
gameMicManager.attachView(SudGameActivity.this);
gameMicManager.config(SudGameActivity.this);
//初始化声网引擎
SWAuManager.get().initRtcEngineAudio(mContext);
//语音
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);
}
});
}, 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.setmRoomID(mLiveUid);
if (isSw) {
SWAuManager.get().joinAudioRoom("v" + mLiveUid, CommonAppConfig.SWToken, Integer.parseInt(CommonAppConfig.getInstance().getUid()));
onJoinRoomSuccess(null);
onJoinSuccess();
} else {
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);
}
});
}
private void onJoinSuccess() {
RongChatRoomClient.getInstance().joinChatRoom("v" + mLiveUid, -1, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
Log.i("tx", "加入成功");
gameMicManager.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");
}
}
});
}
@Override
protected void onDestroy() {
LiveNetManager.get(mContext)
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
LiveNetManager.get(mContext).leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
}
@Override
public void onError(String error) {
}
});
@Override
public void onError(String error) {
}
});
if(isSw){
SWAuManager.get().exitChannelAll();
}
if (gameMicManager != null) {
gameMicManager.leaveRoom();
gameMicManager.detachView();
}
Bus.getOff(this);
super.onDestroy();
@ -225,8 +260,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
chatList = findViewById(R.id.chat_list);
userList = findViewById(R.id.user_list);
//聊天栏
FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams)
chatList.getLayoutParams();
FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) chatList.getLayoutParams();
params1.topMargin = DpUtil.dp2px(65);
chatList.setLayoutParams(params1);
@ -245,7 +279,13 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
@Override
public void unMute(String userID, int position) {
if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
gameMicManager.refreshStreams(userID, false, position);
if (isSw) {
//靜音
SWAuManager.get().setMicAudio(Integer.parseInt(userID), false);
onSubscribeSuccess(userID, false, position);
} else {
gameMicManager.refreshStreams(userID, false, position);
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
@ -256,11 +296,16 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
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);
if (isSw) {
//开启声音
SWAuManager.get().setMicAudio(Integer.parseInt(userID), true);
onSubscribeSuccess(userID, true, position);
} else {
gameMicManager.refreshStreams(userID, true, position);
}
} else {
ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
}
}
@Override
@ -292,9 +337,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
@Override
public void onViewClicks() {
new XPopup.Builder(mContext)
.enableDrag(false)
.asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
new XPopup.Builder(mContext).enableDrag(false).asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
}
});
@ -306,16 +349,27 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
if (publishDefault) {
disable = true;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
if (isSw) {
//下麥
SWAuManager.get().setMicAn(false);
onUnPublishStreamsSuccess();
} else {
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
// ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
gameMicManager.unPublishStreams();
gameMicManager.unPublishStreams();
}
} else {
if (sudGameUserListAdapter.isMicMax()) {
ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
} else {
gameMicManager.publishDefaultAVStream();
//上麦
if (isSw) {
SWAuManager.get().setMicAn(true);
onPublishSuccess();
} else {
gameMicManager.publishDefaultAVStream();
}
}
}
} else {
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@ -326,8 +380,6 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
});
}
}
}
});
ViewClicksAntiShake.clicksAntiShake(gameCloseWheat, new ViewClicksAntiShake.ViewClicksCallBack() {
@ -341,38 +393,44 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
if (disable) {
disable = false;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
if (isSw) {
SWAuManager.get().setMicAn(true);
} else {
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) {
LiveNetManager.get(mContext).onMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
}
@Override
public void onError(String error) {
@Override
public void onError(String error) {
}
});
}
});
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on");
} else {
disable = true;
// 设置禁用麦克风采集
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
if(isSw){
SWAuManager.get().setMicAn(false);
}else{
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) {
LiveNetManager.get(mContext).offMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
}
@Override
public void onError(String error) {
@Override
public void onError(String error) {
}
});
}
});
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off");
}
}
@ -387,15 +445,12 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
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();
new XPopup.Builder(mContext).enableDrag(false).asCustom(new SudGameInputPopupWindow(mContext, new SudGameInputPopupWindow.SudGameInputCallBack() {
@Override
public void sendMessage(String textMessage) {
gameMicManager.sendMessage(textMessage);
}
})).show();
}
});
@ -406,9 +461,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
gameContainer.removeAllViews();
} else { // 把游戏View添加到容器内
gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
}
}
});
// 加载游戏参数定义可查看BaseGameViewModel.switchGame()方法注释
@ -483,30 +536,27 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
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 {
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);
}
});
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
break;
case SudMGPMGState.MG_COMMON_GAME_STATE:
LiveNetManager.get(mContext).deductMoney(mCreateSudRoomModel.getSudGameRoomId());
break;
}
}
@Override
@ -514,7 +564,6 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback<List<SudGameUserModel>>() {
@Override
public void onSuccess(List<SudGameUserModel> data) {
gameMicManager.refreshStreams(data);
sudGameUserListAdapter.refreshSudGameUserList(data, muteUser);
}
@ -548,18 +597,17 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
}
});
LiveNetManager.get(mContext)
.joinMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
LiveNetManager.get(mContext).joinMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
}
@Override
public void onError(String error) {
@Override
public void onError(String error) {
}
});
}
});
}
@Override
@ -628,18 +676,17 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
gameCloseWheat.setVisibility(View.INVISIBLE);
}
});
LiveNetManager.get(mContext)
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
LiveNetManager.get(mContext).leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
@Override
public void onSuccess(HttpCallbackModel data) {
}
}
@Override
public void onError(String error) {
@Override
public void onError(String error) {
}
});
}
});
}

View File

@ -215,6 +215,7 @@ public class LiveNewFunctionDialogFragment extends AbsDialogFragment implements
public void onSuccess(List<CustomSidebarInfoModel> data) {
for (CustomSidebarInfoModel datum : data) {
if (datum.getType().equals("6")) {
//直播间来的
new XPopup.Builder(mContext)
.enableDrag(false)
.moveUpToKeyboard(false)

View File

@ -0,0 +1,9 @@
package com.yunbao.live.event;
/**
* Created by cxf on 2019/3/25.
*/
public class LiveOpenSuccessEvent {
}

View File

@ -102,6 +102,7 @@ import com.yunbao.live.dialog.BlowkissDialog;
import com.yunbao.live.dialog.NewUserDialog;
import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.event.LiveOpenSuccessEvent;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
@ -442,7 +443,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveLinkMicPresenter.setSocketClient(mSocketClient);
}
enterRoomNew();
Bus.get().post(new LiveOpenSuccessEvent());
} catch (Exception e) {
e.printStackTrace();
}
@ -835,6 +836,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
public void loadTimeoutRunnableGone(){
if(liveHandler!=null){
liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000);
}
}
public void removeLiveEnd() {
if (mLiveEndViewHolder != null) {
mLiveEndViewHolder.removeFromParent();