完成了多房间查看的逻辑重构
在停止直播后会退出当前房间
This commit is contained in:
@@ -3,7 +3,7 @@ package com.mogo.cloud.trafficlive.api;
|
||||
import android.app.Application;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.mogo.cloud.trafficlive.core.TrafficLiveManager;
|
||||
import com.mogo.cloud.trafficlive.core.TrafficLiveCurrentManager;
|
||||
import com.mogo.cloud.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.cloud.trafficlive.constant.TrafficLiveConstant.TAG;
|
||||
@@ -15,7 +15,7 @@ public class MoGoAiCloudTrafficLive {
|
||||
*/
|
||||
public static void viewVehicleHeadLive(Application application, String liveSn, SurfaceView surfaceView, ITrafficLiveCallBack callBack) {
|
||||
try {
|
||||
TrafficLiveManager.getInstance().viewVehicleHeadLive(application, liveSn, surfaceView, callBack);
|
||||
TrafficLiveCurrentManager.getInstance().viewVehicleHeadLive(application, liveSn, surfaceView, callBack);
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, " viewVehicleHeadLive error : " + e);
|
||||
e.printStackTrace();
|
||||
@@ -26,21 +26,14 @@ public class MoGoAiCloudTrafficLive {
|
||||
* 查看前方路口直播
|
||||
*/
|
||||
public static void viewIntersectionLive(ITrafficLiveCallBack callBack) {
|
||||
TrafficLiveManager.getInstance().viewIntersectionLive(callBack);
|
||||
TrafficLiveCurrentManager.getInstance().viewIntersectionLive(callBack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止观看直播
|
||||
*/
|
||||
public static void stopLive(String liveSn) {
|
||||
TrafficLiveManager.getInstance().stopLive(liveSn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭直播组件
|
||||
*/
|
||||
public static void destroyLive() {
|
||||
TrafficLiveManager.getInstance().destroyLive();
|
||||
TrafficLiveCurrentManager.getInstance().stopLive(liveSn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,6 +42,6 @@ public class MoGoAiCloudTrafficLive {
|
||||
* @return 直播状态
|
||||
*/
|
||||
public static boolean isOnLive() {
|
||||
return TrafficLiveManager.getInstance().isOnLive();
|
||||
return TrafficLiveCurrentManager.getInstance().isOnLive();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.mogo.cloud.live.listener.ILiveMultiRoomStatusListener;
|
||||
import com.mogo.cloud.live.listener.ILiveProgressListener;
|
||||
import com.mogo.cloud.live.listener.ILiveRoomStatusListener;
|
||||
import com.mogo.cloud.live.listener.ILiveCurrentRoomStatusListener;
|
||||
import com.mogo.cloud.live.listener.IRequestLiveListener;
|
||||
import com.mogo.cloud.live.manager.MoGoLiveManager;
|
||||
import com.mogo.cloud.live.manager.MoGoLivePushConfig;
|
||||
@@ -19,24 +20,26 @@ import static com.mogo.cloud.live.constant.LiveConstant.LIVE_TYPE_CLOSE;
|
||||
import static com.mogo.cloud.live.constant.LiveConstant.LIVE_TYPE_OPEN;
|
||||
import static com.mogo.cloud.trafficlive.constant.TrafficLiveConstant.TAG;
|
||||
|
||||
public class TrafficLiveManager implements ILiveProgressListener, ILiveRoomStatusListener {
|
||||
public class TrafficLiveCurrentManager
|
||||
implements ILiveProgressListener, ILiveMultiRoomStatusListener {
|
||||
|
||||
private static volatile TrafficLiveManager mInstance;
|
||||
private static volatile TrafficLiveCurrentManager mInstance;
|
||||
private final RequestLiveManager requestLiveManager;
|
||||
private ITrafficLiveCallBack trafficLiveCallBack;
|
||||
private SurfaceView surfaceView;
|
||||
private String mStreamId;
|
||||
private boolean isLoginSuccess = false;
|
||||
|
||||
private TrafficLiveManager() {
|
||||
private TrafficLiveCurrentManager() {
|
||||
requestLiveManager = RequestLiveManager.getInstance();
|
||||
}
|
||||
|
||||
public static TrafficLiveManager getInstance() {
|
||||
public static TrafficLiveCurrentManager getInstance() {
|
||||
if (mInstance == null) {
|
||||
synchronized (TrafficLiveManager.class) {
|
||||
synchronized (TrafficLiveCurrentManager.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new TrafficLiveManager();
|
||||
mInstance = new TrafficLiveCurrentManager();
|
||||
MoGoLiveManager.getInstance().addLiveProgressListener(mInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +47,7 @@ public class TrafficLiveManager implements ILiveProgressListener, ILiveRoomStatu
|
||||
}
|
||||
|
||||
public boolean isOnLive() {
|
||||
return MoGoLiveManager.getInstance().isPlaying();
|
||||
return MoGoLiveManager.getInstance().getLiveStatusModel().isPlaying();
|
||||
}
|
||||
|
||||
public void viewVehicleHeadLive(Application application, String liveSn, SurfaceView surfaceView, ITrafficLiveCallBack trafficLiveCallBack) throws Exception {
|
||||
@@ -74,19 +77,18 @@ public class TrafficLiveManager implements ILiveProgressListener, ILiveRoomStatu
|
||||
|
||||
// 登录要查看的SN房间
|
||||
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
|
||||
MoGoLiveManager.getInstance().setLiveProgressListener(TrafficLiveManager.this);
|
||||
|
||||
// 直接 查看对应SN的直播
|
||||
MoGoLiveManager.getInstance().startLive(surfaceView);
|
||||
if (TrafficLiveManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveManager.this.trafficLiveCallBack.onLive();
|
||||
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveCurrentManager.this.trafficLiveCallBack.onLive();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (TrafficLiveManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveManager.this.trafficLiveCallBack.onError(e.getMessage());
|
||||
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveCurrentManager.this.trafficLiveCallBack.onError(e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -116,10 +118,6 @@ public class TrafficLiveManager implements ILiveProgressListener, ILiveRoomStatu
|
||||
mStreamId = null;
|
||||
}
|
||||
|
||||
public void destroyLive() {
|
||||
MoGoLiveManager.getInstance().onDestroyLive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEngineStart() {
|
||||
if (trafficLiveCallBack != null) {
|
||||
@@ -142,20 +140,7 @@ public class TrafficLiveManager implements ILiveProgressListener, ILiveRoomStatu
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoomConnecting() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoomConnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCurrentRoomDisconnected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMultiRoomConnecting() {
|
||||
Reference in New Issue
Block a user