新增直播播放器报错时提示

新增观众端看异常下播直播间提示
This commit is contained in:
zlzw 2023-06-25 14:18:40 +08:00
parent f54054283c
commit 9741be743c
2 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,8 @@ import com.google.android.exoplayer2.analytics.AnalyticsListener;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.StyledPlayerView; import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.google.android.exoplayer2.video.VideoSize; import com.google.android.exoplayer2.video.VideoSize;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
/** /**
* 直播间播放器管理器 * 直播间播放器管理器
@ -38,8 +40,10 @@ public class LiveExoPlayerManager {
private final Handler handler; private final Handler handler;
private static double log_buffer_time = 0, log_buffer_max_time; private static double log_buffer_time = 0, log_buffer_max_time;
private String url = ""; private String url = "";
private Context mContext;
public LiveExoPlayerManager(Context mContext) { public LiveExoPlayerManager(Context mContext) {
this.mContext = mContext;
DefaultLoadControl control = new DefaultLoadControl.Builder() DefaultLoadControl control = new DefaultLoadControl.Builder()
.setPrioritizeTimeOverSizeThresholds(false) .setPrioritizeTimeOverSizeThresholds(false)
.setBackBuffer(10_000, true) .setBackBuffer(10_000, true)
@ -191,6 +195,7 @@ public class LiveExoPlayerManager {
Player.Listener.super.onPlayerError(error); Player.Listener.super.onPlayerError(error);
error.printStackTrace(); error.printStackTrace();
replay(); replay();
ToastUtil.show(mContext.getString(R.string.net_error) + " :" + error.errorCode);
} }
}); });
@ -260,6 +265,7 @@ public class LiveExoPlayerManager {
Player.Listener.super.onPlayerError(error); Player.Listener.super.onPlayerError(error);
error.printStackTrace(); error.printStackTrace();
replay(); replay();
ToastUtil.show(mContext.getString(R.string.net_error) + " :" + error.errorCode);
} }
}); });
} }

View File

@ -257,6 +257,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void run() { public void run() {
loading.setVisibility(View.GONE); loading.setVisibility(View.GONE);
enterRoomLeaveHandler.post(enterRoomLeaveRunnable); enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
ToastUtil.show(mContext.getString(R.string.net_error) + " :500" );//异常下播等待加载时间过了后弹出
} }
}; };