diff --git a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java index 3e5edb01a..f4ed86164 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java @@ -49,6 +49,11 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl selectClarity = 0; } this.isUser = isUser; + if (banSelect == BAN_720) { + selectClarity = 0; + } else if (banSelect == BAN_1080 && selectClarity == 3) { + selectClarity = 2; + } this.selectClarity = selectClarity; } 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 d1536b002..4a810273e 100644 --- a/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java +++ b/live/src/main/java/com/yunbao/live/utils/LiveExoPlayerManager.java @@ -1,7 +1,5 @@ package com.yunbao.live.utils; -import static com.google.android.exoplayer2.C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING; - import android.content.Context; import android.os.Handler; import android.os.Looper; @@ -12,6 +10,7 @@ import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.analytics.AnalyticsListener; +import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.StyledPlayerView; import com.google.android.exoplayer2.video.VideoSize; @@ -52,6 +51,10 @@ public class LiveExoPlayerManager { this.mainView = mainView; this.mainView.setKeepContentOnPlayerReset(true); } + public void setViewResizeMode(boolean isPhone){ + mainView.setResizeMode(isPhone?AspectRatioFrameLayout.RESIZE_MODE_ZOOM:AspectRatioFrameLayout.RESIZE_MODE_FIT); + mainView.requestLayout(); + } private void setAnalyticsListener() { player1.addAnalyticsListener(new AnalyticsListener() { @@ -135,6 +138,7 @@ public class LiveExoPlayerManager { @Override public void onVideoSizeChanged(VideoSize videoSize) { Player.Listener.super.onVideoSizeChanged(videoSize); + setViewResizeMode(videoSize.height>videoSize.width); Log.i(TAG, "onVideoSizeChanged: width = " + videoSize.width + " height = " + videoSize.height); if (listener != null) { listener.onVideoSizeChanged(videoSize); @@ -187,6 +191,7 @@ public class LiveExoPlayerManager { @Override public void onVideoSizeChanged(VideoSize videoSize) { Player.Listener.super.onVideoSizeChanged(videoSize); + setViewResizeMode(videoSize.height>videoSize.width); if (listener != null) { listener.onVideoSizeChanged(videoSize); } @@ -206,7 +211,7 @@ public class LiveExoPlayerManager { * @param url 地址 */ public void startUrl(String url) { - Log.i(TAG, "startUrl: "+url); + Log.i(TAG, "startUrl: "+url+" > "+mainView.getResizeMode()); isSwitchUrl = true; playBufferIndex = 0; //getNowPlayer().setVideoSurfaceView(mainView); 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 e550e8c64..6ae0bb65a 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -192,8 +192,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { @Override public synchronized void setLiveBeanLandscape(int landscape) { +// landscape=1; + Log.i(TAG, "setLiveBeanLandscape: " + landscape); this.landscape = landscape; this.videoLandscape = landscape; + mPlayer.setViewResizeMode(landscape==VIDEO_VERTICAL); if (landscape == 2) { Log.i("收到socket--->", "还原9:16"); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams(); @@ -267,12 +270,16 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void play(String url, int playModel) { srcUrl = url; PLAY_MODEL = playModel; + Log.i(TAG, "play" + " url:" + url + " playModel: " + playModel + " landscape: " + videoLandscape); if (playModel != PLAY_MODEL_DEF) { - if (videoLandscape == VIDEO_VERTICAL) { + mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); + if (landscape == VIDEO_VERTICAL) { url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv"); - } else if (videoLandscape == VIDEO_HORIZONTAL) { + } else if (landscape == VIDEO_HORIZONTAL) { url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv"); } + } else { + mPlayer.setViewResizeMode(false); } Log.e("purl121", url); @@ -295,12 +302,16 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void switchStream(String url, int playModel) { srcUrl = url; PLAY_MODEL = playModel; + Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape); if (playModel != PLAY_MODEL_DEF) { - if (videoLandscape == VIDEO_VERTICAL) { + mPlayer.setViewResizeMode(landscape == VIDEO_VERTICAL); + if (landscape == VIDEO_VERTICAL) { url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv"); - } else if (videoLandscape == VIDEO_HORIZONTAL) { + } else if (landscape == VIDEO_HORIZONTAL) { url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv"); } + } else { + mPlayer.setViewResizeMode(false); } Log.e("purl121", url); @@ -348,6 +359,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { public void stopPlay2() { } + @Override public void setViewUP(int i) { if (mVideoView == null) return; @@ -692,7 +704,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { break; } - LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, PLAY_MODEL, ban,true); + LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, PLAY_MODEL, ban, true); new XPopup.Builder(mContext) .setPopupCallback(new XPopupCallback() { @Override diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java index 49f7d01d8..a4dc4c9d2 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java @@ -20,7 +20,7 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL public static final int PLAY_MODEL_1080 = 2; public static int PLAY_MODEL = PLAY_MODEL_DEF; - public static final String[] videoRatioHorizontal = new String[]{"_848_480", "_1280_720", "_1920_1080"}; + public static final String[] videoRatioHorizontal = new String[]{"_640_480", "_960_720", "_1440_1080"}; public static final String[] videoRatioVertical = new String[]{"_480_848", "_720_1280", "_1080_1920"}; public static final String[] videoFps = new String[]{"_24", "_30"}; OnMicCallback onMicCallback;//连麦回调 diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 9fcf3ef3d..8c6c80337 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -299,6 +299,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mask.setVisibility(View.VISIBLE); mLivePlayViewHolder.setLiveBean(mLiveBean); mLivePlayViewHolder.setCover(mLiveBean.getAvatar()); + mLivePlayViewHolder.setLiveBeanLandscape(mLiveBean.getLandscape()); mLivePlayViewHolder.play(mLiveBean.getPull(), LiveRoomPlayViewHolder.PLAY_MODEL_720); mLivePlayViewHolder.setOnMicCallback(new LiveRoomPlayViewHolder.OnMicCallback() { @Override @@ -357,7 +358,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe landscape = data.getLiveInfo().getLandscape(); mLivePlayViewHolder.setLiveBeanLandscape(landscape); mLivePlayViewHolder.setLiveEnterRoomNewModel(data); - //mLivePlayViewHolder.switchStream(mLiveBean.getPull(), (data.getClarityType() - 1) == 2 ? 1 : (data.getClarityType() - 1)); + mLivePlayViewHolder.switchStream(mLiveBean.getPull(), (data.getClarityType() - 1) == 2 ? 1 : (data.getClarityType() - 1)); //是否热度卡加成 liveHandler.postDelayed(() -> mLiveRoomViewHolder.getIsHot(data.getIsUseHotCard()), 700); diff --git a/live/src/main/res/layout/view_live_play_ksy.xml b/live/src/main/res/layout/view_live_play_ksy.xml index a7b2b1a81..91b5d0346 100644 --- a/live/src/main/res/layout/view_live_play_ksy.xml +++ b/live/src/main/res/layout/view_live_play_ksy.xml @@ -11,7 +11,6 @@ android:id="@+id/video_view" android:layout_width="match_parent" app:surface_type="texture_view" - app:resize_mode="zoom" app:use_controller="false" android:layout_height="match_parent" />