Merge branch 'fix_loginMultiRoom_bug'
# Conflicts: # .idea/misc.xml # gradle.properties
This commit is contained in:
@@ -67,12 +67,12 @@ public class LivePlayActivity extends AppCompatActivity implements ITrafficCarLi
|
||||
|
||||
@Override
|
||||
public void onDisConnect() {
|
||||
Log.d(TAG, "失去连接 onDisConnect");
|
||||
Log.w(TAG, "失去连接 onDisConnect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String errorMsg) {
|
||||
Log.d(TAG, "发生错误 onError msg: " + errorMsg);
|
||||
Log.e(TAG, "发生错误 onError msg: " + errorMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.elegant.log.simplelog.Logger;
|
||||
import com.mogo.cloud.live.listener.ILiveRoomPersonListener;
|
||||
import com.mogo.cloud.live.listener.ILiveStatusListener;
|
||||
import com.mogo.cloud.live.model.CommandModel;
|
||||
import com.mogo.cloud.live.server.PushService;
|
||||
@@ -14,13 +15,18 @@ import com.mogo.cloud.live.socket.SocketRequestUtils;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import im.zego.zegoexpress.constants.ZegoUpdateType;
|
||||
import im.zego.zegoexpress.entity.ZegoUser;
|
||||
|
||||
|
||||
/**
|
||||
* 直播流管理实现类
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
public class LiveStreamManagerImpl implements ILiveStreamManager, ILiveRoomPersonListener {
|
||||
private static final String TAG = "LiveStreamManagerImpl";
|
||||
|
||||
private static volatile LiveStreamManagerImpl sInstance;
|
||||
@@ -86,6 +92,8 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
}
|
||||
// 开启房间人数检测
|
||||
restartCheckOnlineNumLoop();
|
||||
// 注册监听
|
||||
MoGoLiveManager.addLiveRoomPersonListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,10 +227,6 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
mMoGoLiveManager.getLiveStatusModel().getOnlineNumber() <= 1) {
|
||||
livePushHandler(PUSH_STOP, C1);
|
||||
}
|
||||
if (!mMoGoLiveManager.getLiveStatusModel().isPushing() &&
|
||||
mMoGoLiveManager.getLiveStatusModel().getOnlineNumber() >= 2) {
|
||||
livePushHandler(PUSH_START, C1);
|
||||
}
|
||||
restartCheckOnlineNumLoop();
|
||||
};
|
||||
|
||||
@@ -258,4 +262,23 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoomOnlineUserCountUpdate(int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoomUserUpdate(ZegoUpdateType updateType, ArrayList<ZegoUser> userList) {
|
||||
// 判断直播中,观看用户等于1,关闭直播
|
||||
if (mMoGoLiveManager.getLiveStatusModel().isPushing() &&
|
||||
mMoGoLiveManager.getLiveStatusModel().getOnlineNumber() <= 1) {
|
||||
livePushHandler(PUSH_STOP, C1);
|
||||
}
|
||||
// 判断没有直播,并且观看用户大于2,开启直播
|
||||
if (!mMoGoLiveManager.getLiveStatusModel().isPushing() &&
|
||||
mMoGoLiveManager.getLiveStatusModel().getOnlineNumber() >= 2) {
|
||||
livePushHandler(PUSH_START, C1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ import im.zego.zegoexpress.entity.ZegoVideoFrameParam;
|
||||
* 即构直播管理
|
||||
*/
|
||||
public class MoGoLiveManager {
|
||||
public static final String TAG = "ZeGoLiveManager";
|
||||
public static final String TAG = "MoGoLiveManager";
|
||||
|
||||
/**
|
||||
* 即构平台分配 APP_ID
|
||||
@@ -109,11 +109,11 @@ public class MoGoLiveManager {
|
||||
/**
|
||||
* 直播房间人员状态
|
||||
*/
|
||||
private ILiveRoomPersonListener mRoomPersonListener;
|
||||
private static final List<ILiveRoomPersonListener> mRoomPersonListener = new ArrayList<>();
|
||||
/**
|
||||
* 直播状态回调
|
||||
*/
|
||||
private ILiveStatusListener mLiveStatusListener;
|
||||
private static final List<ILiveStatusListener> mLiveStatusListener = new ArrayList<>();
|
||||
/**
|
||||
* 直播数据
|
||||
*/
|
||||
@@ -267,8 +267,10 @@ public class MoGoLiveManager {
|
||||
}
|
||||
Log.i(TAG, "房间内当前在线用户数量回调 onRoomOnlineUserCountUpdate roomID : " + roomID +
|
||||
" , online user number : " + mLiveStatusModel.getOnlineNumber());
|
||||
if (mRoomPersonListener != null) {
|
||||
mRoomPersonListener.onRoomOnlineUserCountUpdate(count);
|
||||
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
|
||||
if (iLiveRoomPersonListener != null) {
|
||||
iLiveRoomPersonListener.onRoomOnlineUserCountUpdate(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,8 +291,10 @@ public class MoGoLiveManager {
|
||||
Log.i(TAG, "房间内其他用户增加或减少的通知回调 onRoomUserUpdate roomId : " + roomID +
|
||||
" , updateType : " + updateType.name() +
|
||||
" , online user number : " + mLiveStatusModel.getOnlineNumber());
|
||||
if (mRoomPersonListener != null) {
|
||||
mRoomPersonListener.onRoomUserUpdate(updateType, userList);
|
||||
for (ILiveRoomPersonListener iLiveRoomPersonListener : mRoomPersonListener) {
|
||||
if (iLiveRoomPersonListener != null) {
|
||||
iLiveRoomPersonListener.onRoomUserUpdate(updateType, userList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,9 +320,10 @@ public class MoGoLiveManager {
|
||||
// && mLiveStatusModel.getOnlineNumber() <= 1) {
|
||||
// logoutCurrentRoom();
|
||||
// }
|
||||
|
||||
if (mLiveStatusListener != null) {
|
||||
mLiveStatusListener.onChange(mLiveStatusModel.isPushing() ? 0 : 1);
|
||||
for (ILiveStatusListener iLiveStatusListener : mLiveStatusListener) {
|
||||
if (iLiveStatusListener != null) {
|
||||
iLiveStatusListener.onChange(mLiveStatusModel.isPushing() ? 0 : 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,17 +435,17 @@ public class MoGoLiveManager {
|
||||
*
|
||||
* @param roomPersonListener 监听回调用
|
||||
*/
|
||||
public void addLiveRoomPersonListener(ILiveRoomPersonListener roomPersonListener) {
|
||||
this.mRoomPersonListener = roomPersonListener;
|
||||
public static void addLiveRoomPersonListener(ILiveRoomPersonListener roomPersonListener) {
|
||||
mRoomPersonListener.add(roomPersonListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播状态回调
|
||||
*
|
||||
* @param mLiveStatusListener 回调监听
|
||||
* @param liveStatusListener 回调监听
|
||||
*/
|
||||
public void setLiveStatusListener(ILiveStatusListener mLiveStatusListener) {
|
||||
this.mLiveStatusListener = mLiveStatusListener;
|
||||
public static void setLiveStatusListener(ILiveStatusListener liveStatusListener) {
|
||||
mLiveStatusListener.add(liveStatusListener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user