优化已经在多人PK时不再切换默认流分辨率

This commit is contained in:
zlzw 2023-01-10 15:35:15 +08:00
parent 872245c9c9
commit 518e57ee44
2 changed files with 19 additions and 10 deletions

View File

@ -34,7 +34,7 @@ public class LiveExoPlayerManager {
private int playBufferIndex = 0;//卡顿计数器
private final Handler handler;
private static double log_buffer_time = 0, log_buffer_max_time;
private String url;
private String url="";
public LiveExoPlayerManager(Context mContext) {
DefaultLoadControl control = new DefaultLoadControl.Builder()
@ -71,6 +71,10 @@ public class LiveExoPlayerManager {
mainView.requestLayout();
}
public boolean isViewResizeModeToPhone() {
return mainView.getResizeMode() == AspectRatioFrameLayout.RESIZE_MODE_ZOOM;
}
private void setAnalyticsListener() {
player1.addAnalyticsListener(new AnalyticsListener() {
@Override
@ -240,6 +244,7 @@ public class LiveExoPlayerManager {
* @param url 地址
*/
public void startUrl(String url) {
if(url.equals(this.url))return;
Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode());
this.url = url;
isSwitchUrl = true;
@ -260,7 +265,8 @@ public class LiveExoPlayerManager {
* @param url 地址
*/
public void switchUrl(String url) {
Log.i(TAG, "switchUrl: " + url);
if(url.equals(this.url))return;
Log.i(TAG, "switchUrl: " + url +" src : "+this.url);
this.url = url;
playBufferIndex = 0;
isSwitchUrl = true;
@ -322,8 +328,8 @@ public class LiveExoPlayerManager {
}
public String getUrl() {
if(url==null){
url="";
if (url == null) {
url = "";
}
return url;
}

View File

@ -283,9 +283,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
if (landscape == VIDEO_VERTICAL && !isPk) {
waitNextUrl = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
} else if (landscape == VIDEO_HORIZONTAL || isPk) {
waitNextUrl = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
}
} else if (!url.contains(videoFps[0] + ".flv")) {
mPlayer.setViewResizeMode(false);
@ -342,9 +342,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override
public void switchStreamPk(boolean isPk) {
super.switchStreamPk(isPk);
Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2" + this.isPk);
Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2 = " + this.isPk);
if(this.isPk&&tmpPk)return;
if (isPk && !tmpPk || this.isPk) {
tmpPk = true;
mPlayer.setViewResizeMode(false);
String url;
if (PLAY_MODEL != -1) {
@ -352,8 +352,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} else {
url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv");
}
waitNextUrl = url;
if (!tmpPk) {
waitNextUrl = url;
}
mPlayer.switchUrl(srcUrl);
tmpPk = true;
} else if (!isPk) {
tmpPk = false;
if (landscape == VIDEO_VERTICAL && PLAY_MODEL != -1) {
@ -1158,7 +1161,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Player.Listener.super.onIsPlayingChanged(isPlaying);
if (isPlaying) {
hideCover();
Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = "+waitNextUrl);
Log.i(TAG, "onIsPlayingChanged: 开始播放 | waitNextUrl = " + waitNextUrl);
OkDownload.getInstance().startAll();
if (loadingListener != null) {
loadingListener.onPlayer();