[Fix]修复触发直播的触发,采用房间更新的接口,更加即时。
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -12,6 +12,7 @@
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="app/src/main/res/layout/actitity_config_info.xml" value="0.35260416666666666" />
|
||||
<entry key="app/src/main/res/layout/activity_live_play.xml" value="0.16354166666666667" />
|
||||
<entry key="app/src/main/res/layout/activity_live_play_and_push.xml" value="0.25" />
|
||||
<entry key="app/src/main/res/layout/activity_live_push.xml" value="0.3640625" />
|
||||
<entry key="app/src/main/res/layout/activity_location.xml" value="0.36502448356535333" />
|
||||
|
||||
@@ -66,12 +66,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ import im.zego.zegoexpress.entity.ZegoVideoFrameParam;
|
||||
* 即构直播管理
|
||||
*/
|
||||
public class MoGoLiveManager {
|
||||
public static final String TAG = "ZeGoLiveManager";
|
||||
public static final String TAG = "MoGoLiveManager";
|
||||
|
||||
/**
|
||||
* 即构平台分配 APP_ID
|
||||
@@ -108,11 +108,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<>();
|
||||
/**
|
||||
* 直播数据
|
||||
*/
|
||||
@@ -266,8 +266,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,8 +290,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,9 +319,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -429,17 +434,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,22 +30,22 @@ PASSWORD=xintai2018
|
||||
RELEASE=true
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.1.59-live
|
||||
MOGO_UTILS_VERSION=1.1.61-live
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.1.59-live
|
||||
MOGO_NETWORK_VERSION=1.1.61-live
|
||||
# 网络DNS
|
||||
MOGO_HTTPDNS_VERSION=1.1.59-live
|
||||
MOGO_HTTPDNS_VERSION=1.1.61-live
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.1.59-live
|
||||
MOGO_PASSPORT_VERSION=1.1.61-live
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.1.59-live
|
||||
MOGO_SOCKET_VERSION=1.1.61-live
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.1.59-live
|
||||
MOGO_REALTIME_VERSION=1.1.61-live
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.1.59-live
|
||||
MOGO_TANLU_VERSION=1.1.61-live
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.1.59-live
|
||||
MOGO_LIVE_VERSION=1.1.61-live
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.1.59-live
|
||||
MOGO_TRAFFICLIVE_VERSION=1.1.61-live
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.1.59-live
|
||||
MOGO_LOCATION_VERSION=1.1.61-live
|
||||
|
||||
Reference in New Issue
Block a user