Merge添加第一帧画面和错误相关的回调函数

This commit is contained in:
chenfufeng
2021-11-11 21:31:40 +08:00
committed by donghongyu
parent 8736a3c226
commit 8c0982b150
7 changed files with 130 additions and 1 deletions

View File

@@ -13,6 +13,10 @@ public interface ITrafficCarLiveCallBack {
void onLive(String liveSn);
default void onFirstFrame() {
}
void onDisConnect();
void onError(String errorMsg);

View File

@@ -5,6 +5,7 @@ import android.view.SurfaceView;
import com.mogo.cloud.live.listener.ILiveMultiRoomStatusListener;
import com.mogo.cloud.live.listener.ILiveProgressListener;
import com.mogo.cloud.live.listener.IMediaPlayerStateListener;
import com.mogo.cloud.live.listener.IRequestLiveListener;
import com.mogo.cloud.live.manager.MoGoLiveManager;
import com.mogo.cloud.live.manager.MoGoLivePushConfig;
@@ -113,6 +114,7 @@ public class TrafficLiveCurrentManager
mLivePushConfig.setDevicesId(sn);
// 登录要查看的SN房间
MoGoLiveManager.getInstance().loginMultiRoom(liveSn);
MoGoLiveManager.getInstance().setMediaPlayerStateListener(mediaPlayerStateListener);
// 直接 查看对应SN的直播
MoGoLiveManager.getInstance().startLive(surfaceView);
if (TrafficLiveCurrentManager.this.trafficLiveCallBack != null) {
@@ -218,5 +220,33 @@ public class TrafficLiveCurrentManager
trafficLiveCallBack.onDisConnect();
}
}
private IMediaPlayerStateListener mediaPlayerStateListener = new IMediaPlayerStateListener() {
@Override
public void onVideoFirstFrame() {
if (trafficLiveCallBack != null) {
trafficLiveCallBack.onFirstFrame();
}
}
@Override
public void remoteDeviceError() {
if (trafficLiveCallBack != null) {
trafficLiveCallBack.onError("");
}
}
@Override
public void onPullStreamError(int errorCode) {
if (trafficLiveCallBack != null) {
trafficLiveCallBack.onError("" + errorCode);
}
}
@Override
public void onDeviceError(int errorCode) {
if (trafficLiveCallBack != null) {
trafficLiveCallBack.onError("" + errorCode);
}
}
};
}