捕获直播异常情况

This commit is contained in:
董宏宇
2020-07-23 15:43:35 +08:00
parent 9dc635cd9b
commit 8ff409d354
2 changed files with 42 additions and 31 deletions

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -25,6 +25,7 @@ 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.TXLivePlayer;
@@ -159,38 +160,48 @@ 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 {
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,
"直播信息= " + 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));
}
}