From b981bd9103ae3bf1ed3c314a71d4d27bfe26b84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Thu, 23 Jul 2020 16:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=92=AD=E5=87=BA=E7=9B=B4=E6=92=AD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/v2x/view/V2XLiveGSYVideoView.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XLiveGSYVideoView.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XLiveGSYVideoView.java index ddb0849b1b..cf25fe1b0d 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XLiveGSYVideoView.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/view/V2XLiveGSYVideoView.java @@ -28,6 +28,7 @@ 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; @@ -54,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) { @@ -85,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); @@ -131,6 +139,7 @@ public class V2XLiveGSYVideoView extends RoundLayout { .livePush(new V2XRefreshCallback() { @Override public void onSuccess(V2XLivePushVoRes result) { + Logger.e(MODULE_NAME, "从服务端获取最新直播信息:" + GsonUtil.jsonFromObject(result)); mClLoadError.setVisibility(GONE); mClLoadError.setVisibility(GONE); try { @@ -161,7 +170,6 @@ public class V2XLiveGSYVideoView extends RoundLayout { */ private void playLiveVideo(MarkerCarInfo.CarLiveInfo carLiveInfo) { try { - startHeartLive(carLiveInfo); if (mLivePlayer != null) { mLivePlayer.startPlay(carLiveInfo.getVideoUrl(), TXLivePlayer.PLAY_TYPE_LIVE_RTMP); mLivePlayer.setPlayListener(new ITXLivePlayListener() { @@ -178,7 +186,7 @@ public class V2XLiveGSYVideoView extends RoundLayout { mLoading.setVisibility(GONE); mClLoadError.setVisibility(GONE); } else if (event < 0) { - AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取识别,可以对我说重试", null); + AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取失败,可以对我说重试", null); stopLive(mCarLiveInfo); mLoading.setVisibility(GONE); mClLoadError.setVisibility(VISIBLE); @@ -205,10 +213,14 @@ public class V2XLiveGSYVideoView extends RoundLayout { } } - // 刷新直播心跳 + /** + * 刷新直播心跳 + * + * @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()