[Update]增加api支持TextureView播放直播
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.cloud.trafficlive.api;
|
||||
|
||||
import android.view.SurfaceView;
|
||||
import android.view.TextureView;
|
||||
|
||||
import com.elegant.log.simplelog.Logger;
|
||||
import com.mogo.cloud.trafficlive.core.TrafficLiveCurrentManager;
|
||||
@@ -45,6 +46,16 @@ public class MoGoAiCloudTrafficLive {
|
||||
}
|
||||
}
|
||||
|
||||
public static void viewDesignativeVehicleLive(String liveSn, TextureView textureView, ITrafficCarLiveCallBack callBack) {
|
||||
try {
|
||||
TrafficLiveCurrentManager.getInstance().viewDesignativeVehicleLive(liveSn, textureView, callBack);
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, " viewDesignativeVehicleLive error : " + e);
|
||||
callBack.onError(e != null ? e.getMessage() : "check input param");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看前方路口直播
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.cloud.trafficlive.core;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.TextureView;
|
||||
|
||||
import com.elegant.log.simplelog.Logger;
|
||||
import com.mogo.cloud.live.listener.ILiveMultiRoomStatusListener;
|
||||
@@ -74,6 +75,31 @@ public class TrafficLiveCurrentManager
|
||||
});
|
||||
}
|
||||
|
||||
public void viewDesignativeVehicleLive(String liveSn, TextureView textureView, ITrafficCarLiveCallBack callBack) throws Exception {
|
||||
if (callBack == null) {
|
||||
throw new Exception("ITrafficLiveCallBack can not be null");
|
||||
}
|
||||
if (textureView == null) {
|
||||
throw new Exception("SurfaceView can not be null");
|
||||
}
|
||||
if (TextUtils.isEmpty(liveSn)) {
|
||||
throw new Exception("liveSn can not be null");
|
||||
}
|
||||
|
||||
this.trafficLiveCallBack = callBack;
|
||||
requestLiveManager.requestDesignativeVehicleLive(LIVE_TYPE_OPEN, liveSn, new IRequestLiveListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
onVehicleLiveSuccess(liveSn, textureView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
onVehicleLiveError(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void viewDesignativeVehicleLive(String liveSn, SurfaceView surfaceView, ITrafficCarLiveCallBack callBack) throws Exception {
|
||||
if (callBack == null) {
|
||||
throw new Exception("ITrafficLiveCallBack can not be null");
|
||||
@@ -99,6 +125,7 @@ public class TrafficLiveCurrentManager
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void onVehicleLiveSuccess(String liveSn, SurfaceView surfaceView) {
|
||||
if (TextUtils.isEmpty(liveSn)) {
|
||||
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
|
||||
@@ -122,6 +149,29 @@ public class TrafficLiveCurrentManager
|
||||
}
|
||||
}
|
||||
|
||||
private void onVehicleLiveSuccess(String liveSn, TextureView textureView) {
|
||||
if (TextUtils.isEmpty(liveSn)) {
|
||||
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveCurrentManager.this.trafficLiveCallBack.onError("There are no live vehicles ahead !");
|
||||
} else {
|
||||
Logger.e(TAG, "onVehicleLiveSuccess , but result liveSn is null");
|
||||
}
|
||||
return;
|
||||
}
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
// 初始化配置文件
|
||||
MoGoLivePushConfig mLivePushConfig = MoGoLivePushConfig.getInstance();
|
||||
mLivePushConfig.setDevicesId(sn);
|
||||
// 登录要查看的SN房间
|
||||
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
|
||||
MoGoLiveManager.getInstance().setMediaPlayerStateListener(mediaPlayerStateListener);
|
||||
// 直接 查看对应SN的直播
|
||||
MoGoLiveManager.getInstance().startLive(textureView);
|
||||
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveCurrentManager.this.trafficLiveCallBack.onLive(liveSn);
|
||||
}
|
||||
}
|
||||
|
||||
private void onVehicleLiveError(String errorMsg) {
|
||||
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
|
||||
TrafficLiveCurrentManager.this.trafficLiveCallBack.onError(errorMsg);
|
||||
|
||||
Reference in New Issue
Block a user