调整播放器拉升问题5

This commit is contained in:
zlzw 2023-01-09 16:20:54 +08:00
parent 93e2a8af02
commit cc4cc2f746
3 changed files with 19 additions and 6 deletions

View File

@ -34,6 +34,7 @@ public class LiveExoPlayerManager {
private int playBufferIndex = 0;//卡顿计数器 private int playBufferIndex = 0;//卡顿计数器
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;
public LiveExoPlayerManager(Context mContext) { public LiveExoPlayerManager(Context mContext) {
DefaultLoadControl control = new DefaultLoadControl.Builder() DefaultLoadControl control = new DefaultLoadControl.Builder()
@ -240,6 +241,7 @@ public class LiveExoPlayerManager {
*/ */
public void startUrl(String url) { public void startUrl(String url) {
Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode()); Log.i(TAG, "startUrl: " + url + " > " + mainView.getResizeMode());
this.url = url;
isSwitchUrl = true; isSwitchUrl = true;
playBufferIndex = 0; playBufferIndex = 0;
log_buffer_time = System.currentTimeMillis(); log_buffer_time = System.currentTimeMillis();
@ -259,6 +261,7 @@ public class LiveExoPlayerManager {
*/ */
public void switchUrl(String url) { public void switchUrl(String url) {
Log.i(TAG, "switchUrl: " + url); Log.i(TAG, "switchUrl: " + url);
this.url = url;
playBufferIndex = 0; playBufferIndex = 0;
isSwitchUrl = true; isSwitchUrl = true;
log_buffer_time = System.currentTimeMillis(); log_buffer_time = System.currentTimeMillis();
@ -317,4 +320,11 @@ public class LiveExoPlayerManager {
player1.release(); player1.release();
player2.release(); player2.release();
} }
public String getUrl() {
if(url==null){
url="";
}
return url;
}
} }

View File

@ -314,9 +314,9 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape); Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape);
if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) { if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL);
if (landscape == VIDEO_VERTICAL) { if (landscape == VIDEO_VERTICAL && !isPk) {
url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv"); url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
} else if (landscape == VIDEO_HORIZONTAL) { } else if (landscape == VIDEO_HORIZONTAL || isPk) {
url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv"); url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
} }
} else if (!url.contains(videoFps[0] + ".flv")) { } else if (!url.contains(videoFps[0] + ".flv")) {
@ -341,7 +341,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
@Override @Override
public void switchStreamPk(boolean isPk) { public void switchStreamPk(boolean isPk) {
super.switchStreamPk(isPk); super.switchStreamPk(isPk);
if (isPk && !srcUrl.contains(videoFps[0] + ".flv") && !tmpPk) { if (isPk && !tmpPk) {
tmpPk = true; tmpPk = true;
mPlayer.setViewResizeMode(false); mPlayer.setViewResizeMode(false);
String url; String url;
@ -404,6 +404,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
params1.addRule(RelativeLayout.ALIGN_TOP); params1.addRule(RelativeLayout.ALIGN_TOP);
ry_view.requestLayout(); ry_view.requestLayout();
isPk=true;
if (mPlayer.getUrl().contains("848_24.flv") || mPlayer.getUrl().contains("1280_24.flv")) {
tmpPk = false;
switchStreamPk(true);
}
} }
/** /**

View File

@ -1305,9 +1305,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.hotAddVisibility(isPk); mLiveRoomViewHolder.hotAddVisibility(isPk);
} }
if(mLivePlayViewHolder!=null){
mLivePlayViewHolder.switchStreamPk(isPk);
}
} }
@Override @Override