加入了多房间登录操作来解决同一设备推流同时拉流
This commit is contained in:
@@ -8,6 +8,7 @@ import android.view.SurfaceView;
|
||||
import com.mogo.cloud.live.listener.ILiveProgressListener;
|
||||
import com.mogo.cloud.live.listener.IRequestLiveListener;
|
||||
import com.mogo.cloud.live.manager.MoGoLiveManager;
|
||||
import com.mogo.cloud.live.manager.MoGoLivePushConfig;
|
||||
import com.mogo.cloud.live.manager.RequestLiveManager;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.trafficlive.api.ITrafficLiveCallBack;
|
||||
@@ -65,18 +66,27 @@ public class TrafficLiveManager implements ILiveProgressListener {
|
||||
Logger.i(TAG, "主播开始直播了 systemClock :" + SystemClock.elapsedRealtime() + " SystemTime : " + System.currentTimeMillis());
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
mStreamId = MoGoLiveManager.STREAM_ID_PREFIX + liveSn;
|
||||
MoGoLiveManager.getInstance().init(application, null);
|
||||
MoGoLiveManager.getInstance().loginRoom(sn, liveSn);
|
||||
|
||||
// 初始化配置文件
|
||||
MoGoLivePushConfig mLivePushConfig = MoGoLivePushConfig.getInstance();
|
||||
mLivePushConfig.setDevicesId(sn);
|
||||
|
||||
MoGoLiveManager.getInstance().init(application, mLivePushConfig);
|
||||
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
|
||||
MoGoLiveManager.getInstance().setLiveProgressListener(TrafficLiveManager.this);
|
||||
|
||||
// 直接 查看对应SN的直播
|
||||
MoGoLiveManager.getInstance().startLive(surfaceView);
|
||||
callBack.onLive();
|
||||
if (callBack != null) {
|
||||
callBack.onLive();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
callBack.onError(e.getMessage());
|
||||
if (callBack != null) {
|
||||
callBack.onError(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -93,7 +103,9 @@ public class TrafficLiveManager implements ILiveProgressListener {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
callBack.onError(e.getMessage());
|
||||
if (callBack != null) {
|
||||
callBack.onError(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
MoGoLiveManager.getInstance().stopLive();
|
||||
@@ -109,34 +121,46 @@ public class TrafficLiveManager implements ILiveProgressListener {
|
||||
|
||||
@Override
|
||||
public void onEngineStart() {
|
||||
callBack.onLiveStart();
|
||||
if (callBack != null) {
|
||||
callBack.onLiveStart();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEngineStop() {
|
||||
callBack.onLiveStop();
|
||||
if (callBack != null) {
|
||||
callBack.onLiveStop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnecting() {
|
||||
callBack.onLiveConnecting();
|
||||
if (callBack != null) {
|
||||
callBack.onLiveConnecting();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(String roomId) {
|
||||
isLoginSuccess = true;
|
||||
callBack.onLiveConnected();
|
||||
if (callBack != null) {
|
||||
callBack.onLiveConnected();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisConnect() {
|
||||
isLoginSuccess = false;
|
||||
callBack.onDisConnect();
|
||||
if (callBack != null) {
|
||||
callBack.onDisConnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDebugError(int errorCode, String funcName, String errorInfo) {
|
||||
Logger.e(TAG, "onDebugError errorCode : " + errorCode + " funcName : " + funcName + " errorInfo : " + errorInfo);
|
||||
callBack.onError(errorInfo);
|
||||
if (callBack != null) {
|
||||
callBack.onError(errorInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user