调整播放器拉升问题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 = [
//
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",

View File

@ -45,8 +45,8 @@ public class LiveExoPlayerManager {
50,
100)
.build();
player1 = new ExoPlayer.Builder(mContext).build();
player2 = new ExoPlayer.Builder(mContext).build();
player1 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
player2 = new ExoPlayer.Builder(mContext).setLoadControl(control).build();
player1.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;
String waitNextUrl = null;
@Override
public void switchStreamPk(boolean isPk) {
@ -350,9 +351,18 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
} else {
url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv");
}
mPlayer.switchUrl(url);
waitNextUrl = url;
mPlayer.switchUrl(srcUrl);
} else if (!isPk) {
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);
}
}
@ -477,12 +487,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void setPkview() {
Log.i("收到socket--->", "变成169");
String url = srcUrl;
if (PLAY_MODEL != -1) {
url = url.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
}
isPk = true;
mPlayer.setViewResizeMode(false);
mPlayer.switchUrl(url);
switchStreamPk(true);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = vHeight;
params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
@ -499,11 +504,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (landscape == 2) {
Log.i("收到socket--->", "还原916");
String url = srcUrl;
if (PLAY_MODEL != -1) {
url = url.replace(".flv", videoRatioVertical[PLAY_MODEL] + videoFps[0] + ".flv");
}
mPlayer.setViewResizeMode(true);
mPlayer.switchUrl(url);
switchStreamPk(false);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
@ -1139,7 +1140,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
public void onVideoSizeChanged(VideoSize videoSize) {
Player.Listener.super.onVideoSizeChanged(videoSize);
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) {
videoLandscape = VIDEO_VERTICAL;
} else {
@ -1169,6 +1170,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
if (loadingListener != null) {
loadingListener.onPlayer();
}
if (waitNextUrl != null) {
mPlayer.switchUrl(waitNextUrl);
waitNextUrl = null;
}
}
}
}