Merge branch 'fix_loginMultiRoom_bug'
# Conflicts: # gradle.properties
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="请输入要查看的车机SN"
|
||||
android:text="F803EB2046PZD00274"
|
||||
android:text="F803EB2046PZD00212"
|
||||
android:textColor="#000"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
@@ -5,6 +5,7 @@ import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEV;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_QA;
|
||||
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE;
|
||||
import static im.zego.zegoexpress.constants.ZegoRemoteDeviceState.OPEN;
|
||||
import static im.zego.zegoexpress.constants.ZegoRoomState.DISCONNECTED;
|
||||
|
||||
import android.app.Application;
|
||||
import android.text.TextUtils;
|
||||
@@ -21,6 +22,7 @@ import com.mogo.cloud.live.listener.IMediaPlayerStateListener;
|
||||
import com.mogo.cloud.live.model.LiveStatusModel;
|
||||
import com.mogo.cloud.live.server.PushService;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.cloud.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -50,6 +52,7 @@ import im.zego.zegoexpress.entity.ZegoCustomVideoCaptureConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoEngineConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoEngineProfile;
|
||||
import im.zego.zegoexpress.entity.ZegoPlayerConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoPublisherConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoRoomConfig;
|
||||
import im.zego.zegoexpress.entity.ZegoUser;
|
||||
import im.zego.zegoexpress.entity.ZegoVideoConfig;
|
||||
@@ -61,6 +64,8 @@ import im.zego.zegoexpress.entity.ZegoVideoFrameParam;
|
||||
public class MoGoLiveManager {
|
||||
public static final String TAG = "MoGoLiveManager";
|
||||
|
||||
//这个只是根据业务需求进行设置的变量,具体应用需根据开发者自定义安排。仅供参考
|
||||
public static boolean isFirstLogin = true;
|
||||
/**
|
||||
* 即构平台分配 APP_ID
|
||||
*/
|
||||
@@ -217,10 +222,11 @@ public class MoGoLiveManager {
|
||||
if (mLiveStatusModel.getCurrentRoomId().equals(roomID)) {
|
||||
Log.i(TAG, "房间状态变化通知 onRoomStateUpdate currentRoomId : " + roomID +
|
||||
" state:" + state +
|
||||
" errorCode:" + errorCode);
|
||||
" errorCode:" + errorCode +
|
||||
" extendedData:" + extendedData.toString());
|
||||
|
||||
// 设置当前登录状态
|
||||
mLiveStatusModel.setLoginCurrentRoom(state != ZegoRoomState.DISCONNECTED);
|
||||
mLiveStatusModel.setLoginCurrentRoom(state != DISCONNECTED);
|
||||
//房间状态更新
|
||||
if (state == ZegoRoomState.CONNECTING) {
|
||||
for (ILiveCurrentRoomStatusListener iLiveRoomStatusListener : mRoomStatusListener) {
|
||||
@@ -231,19 +237,40 @@ public class MoGoLiveManager {
|
||||
iLiveRoomStatusListener.onCurrentRoomConnected();
|
||||
}
|
||||
} else {
|
||||
mLiveStatusModel.setLoginCurrentRoom(false);
|
||||
for (ILiveCurrentRoomStatusListener iLiveRoomStatusListener : mRoomStatusListener) {
|
||||
iLiveRoomStatusListener.onCurrentRoomDisconnected();
|
||||
}
|
||||
}
|
||||
//errorCode 不为 0 时,房间状态异常,完整错误状态可参考错误码说明 https://doc-zh.zego.im/article/4378
|
||||
// 处理被踢掉的情况
|
||||
if (errorCode != 0) {
|
||||
Logger.w(TAG, "用户被踢出房间,尝试再次登录……");
|
||||
if (errorCode == 1002053) {
|
||||
//房间连接断开并且重试超时
|
||||
//此时可以在业务中退出房间/直播间/课堂,或者手动调用接口再次登录
|
||||
loginRoom();
|
||||
} else if (errorCode == 1002050) {
|
||||
//用户被踢出房间(由于 userID 相同的用户在其他地方登录)
|
||||
// 再次登录
|
||||
loginRoom();
|
||||
} else if (errorCode == 1002055) {
|
||||
//用户被踢出房间(开发者主动调用后台的踢人接口)
|
||||
|
||||
} else if (errorCode == 1002033) {
|
||||
//当使用登录房间鉴权的功能时,传入的 token 出错导
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 这里回调的是登录的他人房间的状态
|
||||
if (mLiveStatusModel.getMultiRoomId().equals(roomID)) {
|
||||
Log.i(TAG, "这里回调的是登录的他人房间的状态 onRoomStateUpdate multiRoomId : " + roomID +
|
||||
" state:" + state +
|
||||
" errorCode:" + errorCode);
|
||||
" errorCode:" + errorCode +
|
||||
" extendedData:" + extendedData.toString());
|
||||
// 设置第二个房间登录状态
|
||||
mLiveStatusModel.setLoginMultiRoom(state != ZegoRoomState.DISCONNECTED);
|
||||
mLiveStatusModel.setLoginMultiRoom(state != DISCONNECTED);
|
||||
//房间状态更新
|
||||
if (state == ZegoRoomState.CONNECTING) {
|
||||
for (ILiveMultiRoomStatusListener iLiveMultiRoomStatusListener : mMultiRoomStatusListener) {
|
||||
@@ -319,7 +346,8 @@ public class MoGoLiveManager {
|
||||
Log.i(TAG, "推流状态回调 onPublisherStateUpdate streamID : " + streamID +
|
||||
" , isPushing : " + mLiveStatusModel.isPushing() +
|
||||
" , state : " + state.name() +
|
||||
" , errorCode : " + errorCode);
|
||||
" , errorCode : " + errorCode +
|
||||
" , extendedData : " + extendedData.toString());
|
||||
|
||||
// // 判断如果处于非播放和非推流状态则进行登出操作,并释放引擎
|
||||
// if (!mLiveStatusModel.isPlaying()
|
||||
@@ -377,7 +405,9 @@ public class MoGoLiveManager {
|
||||
public void onPlayerRecvVideoFirstFrame(String streamID) {
|
||||
super.onPlayerRecvVideoFirstFrame(streamID);
|
||||
Log.d(TAG, "onPlayerRecvVideoFirstFrame");
|
||||
if (mMediaPlayerStateListener != null) mMediaPlayerStateListener.onVideoFirstFrame();
|
||||
if (mMediaPlayerStateListener != null) {
|
||||
mMediaPlayerStateListener.onVideoFirstFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -493,16 +523,6 @@ public class MoGoLiveManager {
|
||||
profile.application = mApplication;
|
||||
/* 创建引擎 */
|
||||
mExpressEngine = ZegoExpressEngine.createEngine(profile, mEventHandler);
|
||||
|
||||
// mExpressEngine = ZegoExpressEngine.createEngine(
|
||||
// appId,
|
||||
// appKey,
|
||||
// isTestEnv,
|
||||
// ZegoScenario.GENERAL,
|
||||
// mApplication,
|
||||
// mEventHandler);
|
||||
// 关闭日志
|
||||
//mExpressEngine.setDebugVerbose(MoGoAiCloudClientConfig.getInstance().isShowDebugLog(), ZegoLanguage.CHINESE);
|
||||
// true 表示静音(关闭)
|
||||
mExpressEngine.muteMicrophone(true);
|
||||
if (mLivePushConfig != null) {
|
||||
@@ -647,7 +667,9 @@ public class MoGoLiveManager {
|
||||
*/
|
||||
public void startPublish() {
|
||||
Log.i(TAG, "开始推流到ZeGo startPublish currentStreamId : " + mLiveStatusModel.getCurrentStreamId());
|
||||
mExpressEngine.startPublishingStream(mLiveStatusModel.getCurrentStreamId());
|
||||
ZegoPublisherConfig config = new ZegoPublisherConfig();
|
||||
config.roomID = mLiveStatusModel.getCurrentRoomId();
|
||||
mExpressEngine.startPublishingStream(mLiveStatusModel.getCurrentStreamId(), config, ZegoPublishChannel.MAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user