调整播放器拉升问题5

This commit is contained in:
zlzw 2023-01-09 18:30:53 +08:00
parent cc4cc2f746
commit 7070f5c1b4
3 changed files with 23 additions and 18 deletions

View File

@ -10,9 +10,9 @@ ext {
manifestPlaceholders = [ manifestPlaceholders = [
// //
serverHost : "https://napi.yaoulive.com", // serverHost : "https://napi.yaoulive.com",
// //
// serverHost : "https://ceshi.yaoulive.com", serverHost : "https://ceshi.yaoulive.com",
// //
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -45,8 +45,8 @@ public class LiveExoPlayerManager {
50, 50,
100) 100)
.build(); .build();
player1 = new ExoPlayer.Builder(mContext).build(); player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
player2 = new ExoPlayer.Builder(mContext).build(); player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
player1.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING); player1.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
player2.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING); player2.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);

View File

@ -337,6 +337,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} }
boolean tmpPk = false; boolean tmpPk = false;
String waitNextUrl = null;
@Override @Override
public void switchStreamPk(boolean isPk) { public void switchStreamPk(boolean isPk) {
@ -350,9 +351,18 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} else { } else {
url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv"); url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv");
} }
mPlayer.switchUrl(url); waitNextUrl = url;
mPlayer.switchUrl(srcUrl);
} else if (!isPk) { } else if (!isPk) {
tmpPk = false; tmpPk = false;
if (landscape == VIDEO_VERTICAL && PLAY_MODEL != -1) {
waitNextUrl = srcUrl.replace(".flv", videoRatioVertical[PLAY_MODEL] + videoFps[0] + ".flv");
} else if (landscape == VIDEO_HORIZONTAL && PLAY_MODEL != -1) {
waitNextUrl = srcUrl.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
} else {
waitNextUrl = null;
}
mPlayer.switchUrl(srcUrl);
} }
} }
@ -404,7 +414,7 @@ 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; isPk = true;
if (mPlayer.getUrl().contains("848_24.flv") || mPlayer.getUrl().contains("1280_24.flv")) { if (mPlayer.getUrl().contains("848_24.flv") || mPlayer.getUrl().contains("1280_24.flv")) {
tmpPk = false; tmpPk = false;
switchStreamPk(true); switchStreamPk(true);
@ -477,12 +487,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void setPkview() { public void setPkview() {
Log.i("收到socket--->", "变成169"); Log.i("收到socket--->", "变成169");
String url = srcUrl; String url = srcUrl;
if (PLAY_MODEL != -1) { switchStreamPk(true);
url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
}
isPk = true;
mPlayer.setViewResizeMode(false);
mPlayer.switchUrl(url);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight; params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top); params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
@ -499,11 +504,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (landscape == 2) { if (landscape == 2) {
Log.i("收到socket--->", "还原916"); Log.i("收到socket--->", "还原916");
String url = srcUrl; String url = srcUrl;
if (PLAY_MODEL != -1) { switchStreamPk(false);
url = url.replace(".flv", videoRatioVertical[PLAY_MODEL] + videoFps[0] + ".flv");
}
mPlayer.setViewResizeMode(true);
mPlayer.switchUrl(url);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
@ -1139,7 +1140,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void onVideoSizeChanged(VideoSize videoSize) { public void onVideoSizeChanged(VideoSize videoSize) {
Player.Listener.super.onVideoSizeChanged(videoSize); Player.Listener.super.onVideoSizeChanged(videoSize);
Log.i(TAG, "onVideoSizeChanged: width = " + videoSize.width + " height = " + videoSize.height); Log.i(TAG, "onVideoSizeChanged: width = " + videoSize.width + " height = " + videoSize.height);
// ToastUtil.show("分辨率: 宽 = " + videoSize.width + " 高 = " + videoSize.height); ToastUtil.show("分辨率: 宽 = " + videoSize.width + " 高 = " + videoSize.height);
if (videoSize.height > videoSize.width) { if (videoSize.height > videoSize.width) {
videoLandscape = VIDEO_VERTICAL; videoLandscape = VIDEO_VERTICAL;
} else { } else {
@ -1169,6 +1170,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (loadingListener != null) { if (loadingListener != null) {
loadingListener.onPlayer(); loadingListener.onPlayer();
} }
if (waitNextUrl != null) {
mPlayer.switchUrl(waitNextUrl);
waitNextUrl = null;
}
} }
} }
} }