增加了直播重试次数,保证可以播出直播信息
This commit is contained in:
@@ -218,7 +218,6 @@ public class V2XRoadLiveCarWindow extends RelativeLayout
|
||||
// 倒计时
|
||||
if (runnableV2XEvent == null) {
|
||||
runnableV2XEvent = () -> {
|
||||
Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时结束。。。");
|
||||
// 移出Window详细信息
|
||||
mTvEventStubClose.setText((countDownTime--) + "s");
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, 1000);
|
||||
|
||||
@@ -25,8 +25,10 @@ import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceConstants;
|
||||
import com.mogo.module.v2x.voice.V2XVoiceManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.tencent.rtmp.ITXLivePlayListener;
|
||||
import com.tencent.rtmp.TXLiveConstants;
|
||||
import com.tencent.rtmp.TXLivePlayConfig;
|
||||
import com.tencent.rtmp.TXLivePlayer;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
|
||||
@@ -53,6 +55,7 @@ public class V2XLiveGSYVideoView extends RoundLayout {
|
||||
private V2XVoiceCallbackListener v2XVoiceCallbackRefreshListener = new V2XVoiceCallbackListener() {
|
||||
@Override
|
||||
public void onCallback(String command, Intent intent) {
|
||||
//startHeartLive(mCarLiveInfo);
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
if (mCarLiveInfo != null) {
|
||||
@@ -84,6 +87,12 @@ public class V2XLiveGSYVideoView extends RoundLayout {
|
||||
//关键 player 对象与界面 view
|
||||
mLivePlayer.setPlayerView(mTxcVideoView);
|
||||
mLivePlayer.setMute(true);
|
||||
|
||||
TXLivePlayConfig txLivePlayConfig = new TXLivePlayConfig();
|
||||
// 增加重试次数
|
||||
txLivePlayConfig.setConnectRetryCount(30);
|
||||
mLivePlayer.setConfig(txLivePlayConfig);
|
||||
|
||||
mLivePlayer.enableHardwareDecode(true);
|
||||
|
||||
mLoading = findViewById(R.id.loading);
|
||||
@@ -130,6 +139,7 @@ public class V2XLiveGSYVideoView extends RoundLayout {
|
||||
.livePush(new V2XRefreshCallback<V2XLivePushVoRes>() {
|
||||
@Override
|
||||
public void onSuccess(V2XLivePushVoRes result) {
|
||||
Logger.e(MODULE_NAME, "从服务端获取最新直播信息:" + GsonUtil.jsonFromObject(result));
|
||||
mClLoadError.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
try {
|
||||
@@ -159,45 +169,58 @@ public class V2XLiveGSYVideoView extends RoundLayout {
|
||||
* 播放直播流,且开始心跳
|
||||
*/
|
||||
private void playLiveVideo(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
startHeartLive(carLiveInfo);
|
||||
if (mLivePlayer != null) {
|
||||
mLivePlayer.startPlay(carLiveInfo.getVideoUrl(), TXLivePlayer.PLAY_TYPE_LIVE_RTMP);
|
||||
mLivePlayer.setPlayListener(new ITXLivePlayListener() {
|
||||
@Override
|
||||
public void onPlayEvent(int event, Bundle bundle) {
|
||||
Logger.w(MODULE_NAME, "播放器:onPlayEvent==" + event + "===bundle===" + bundle);
|
||||
if (event == TXLiveConstants.PLAY_EVT_PLAY_LOADING) {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event == TXLiveConstants.PLAY_EVT_PLAY_BEGIN) {
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event < 0) {
|
||||
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取识别,可以对我说重试", null);
|
||||
stopLive(mCarLiveInfo);
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(VISIBLE);
|
||||
// 注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_CAR_LIVE,
|
||||
v2XVoiceCallbackRefreshListener)
|
||||
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP,
|
||||
v2XVoiceCallbackRefreshListener);
|
||||
try {
|
||||
if (mLivePlayer != null) {
|
||||
mLivePlayer.startPlay(carLiveInfo.getVideoUrl(), TXLivePlayer.PLAY_TYPE_LIVE_RTMP);
|
||||
mLivePlayer.setPlayListener(new ITXLivePlayListener() {
|
||||
@Override
|
||||
public void onPlayEvent(int event, Bundle bundle) {
|
||||
Logger.w(MODULE_NAME,
|
||||
"直播信息= " + GsonUtil.jsonFromObject(carLiveInfo) +
|
||||
"\n播放器:onPlayEvent==" + event +
|
||||
"\nbundle===" + bundle);
|
||||
if (event == TXLiveConstants.PLAY_EVT_PLAY_LOADING) {
|
||||
mLoading.setVisibility(VISIBLE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event == TXLiveConstants.PLAY_EVT_PLAY_BEGIN) {
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(GONE);
|
||||
} else if (event < 0) {
|
||||
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取失败,可以对我说重试", null);
|
||||
stopLive(mCarLiveInfo);
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(VISIBLE);
|
||||
// 注册语音交互
|
||||
V2XVoiceManager.INSTANCE
|
||||
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_CAR_LIVE,
|
||||
v2XVoiceCallbackRefreshListener)
|
||||
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP,
|
||||
v2XVoiceCallbackRefreshListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetStatus(Bundle bundle) {
|
||||
//Logger.w(MODULE_NAME, "播放器:onNetStatus===bundle===" + bundle);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onNetStatus(Bundle bundle) {
|
||||
Logger.w(MODULE_NAME, "播放器:onNetStatus===bundle===" + bundle);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
mLoading.setVisibility(GONE);
|
||||
mClLoadError.setVisibility(VISIBLE);
|
||||
Logger.e(MODULE_NAME, "直播发生异常:carLiveInfo= " + GsonUtil.jsonFromObject(carLiveInfo));
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新直播心跳
|
||||
/**
|
||||
* 刷新直播心跳
|
||||
*
|
||||
* @param carLiveInfo
|
||||
*/
|
||||
private void startHeartLive(MarkerCarInfo.CarLiveInfo carLiveInfo) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(carLiveInfo.getVideoSn())
|
||||
if (carLiveInfo != null && !TextUtils.isEmpty(carLiveInfo.getVideoSn())
|
||||
&& !TextUtils.isEmpty(carLiveInfo.getVideoChannel())) {
|
||||
V2XServiceManager
|
||||
.getV2XRefreshModel()
|
||||
|
||||
Reference in New Issue
Block a user