From 7070f5c1b49e2eca747d855c50fd00b9017ff6c1 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 9 Jan 2023 18:30:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=92=AD=E6=94=BE=E5=99=A8?= =?UTF-8?q?=E6=8B=89=E5=8D=87=E9=97=AE=E9=A2=985?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.gradle | 4 +-- .../live/utils/LiveExoPlayerManager.java | 4 +-- .../live/views/LivePlayRyViewHolder.java | 33 +++++++++++-------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/config.gradle b/config.gradle index b123cc49e..7bd22a5fb 100644 --- a/config.gradle +++ b/config.gradle @@ -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", diff --git a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java index 0b557d7c9..2372f156a 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java @@ -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); diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 3e5d2353f..cce26f97f 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -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); } } @@ -404,7 +414,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top); params1.addRule(RelativeLayout.ALIGN_TOP); ry_view.requestLayout(); - isPk=true; + isPk = true; if (mPlayer.getUrl().contains("848_24.flv") || mPlayer.getUrl().contains("1280_24.flv")) { tmpPk = false; switchStreamPk(true); @@ -477,12 +487,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void setPkview() { Log.i("收到socket--->", "变成16:9"); 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--->", "还原9:16"); 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; + } } } }