From b3b028c0b6419c15277f1ad78ff7aec9b428b3c6 Mon Sep 17 00:00:00 2001 From: Super <986386695@qq.com> Date: Sat, 18 Jul 2020 14:29:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=99=A8=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E9=80=82=E9=85=8D=E6=A8=A1=E5=BC=8F=EF=BC=9A?= =?UTF-8?q?=20/**=20=20=20=20=20=20=20=20=20=20*=20=E5=85=A8=E5=B1=8F?= =?UTF-8?q?=EF=BC=8C=E5=AE=BD=E9=93=BA=E6=BB=A1=20=E9=AB=98=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=20=20=20=20=20=20=20=20=20=20*/=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20FM=5FFULL=5FSCREEN,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /** * 全屏,高铺满 宽自适应 */ FM_FULL_SCREEN_HEIGHT, /** * 宽高比:16;9 */ FM_WH_16X9 --- .../rxffmpeg/player/MeasureHelper.java | 49 ++++++++++++++++--- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/rxffmpeg/src/main/java/io/microshow/rxffmpeg/player/MeasureHelper.java b/rxffmpeg/src/main/java/io/microshow/rxffmpeg/player/MeasureHelper.java index b5c582d..6d6a92b 100644 --- a/rxffmpeg/src/main/java/io/microshow/rxffmpeg/player/MeasureHelper.java +++ b/rxffmpeg/src/main/java/io/microshow/rxffmpeg/player/MeasureHelper.java @@ -30,9 +30,24 @@ public class MeasureHelper { public enum FitModel { /** - * 默认 + * 默认, 宽铺满,横屏的视频高度自适应,如果是竖屏的视频,高度等于屏幕宽 */ - FM_DEFAULT + FM_DEFAULT, + + /** + * 全屏,宽铺满 高自适应 + */ + FM_FULL_SCREEN, + + /** + * 全屏,高铺满 宽自适应 + */ + FM_FULL_SCREEN_HEIGHT, + + /** + * 宽高比:16;9 + */ + FM_WH_16X9 } @@ -150,17 +165,35 @@ public void setVideoLayoutParams(TextureView textureView, FrameLayout container) viewWidth = (int) (viewHeight * videoAspect); } else {//非全屏 - if (videoWidth > videoHeight) {//横屏视频 + + if (mFitModel == FitModel.FM_FULL_SCREEN) { //宽铺满,高度按比例 viewHeight = (int) (viewWidth / videoAspect); - } else if (videoWidth < videoHeight) {//竖屏视频 - //高铺满 宽自适应 - viewHeight = viewWidth; + } else if (mFitModel == FitModel.FM_FULL_SCREEN_HEIGHT) { + //高度铺满 + viewHeight = Helper.getScreenHeight(getView().getContext()); + //宽自适应 viewWidth = (int) (viewHeight * videoAspect); - } else {//正方形视频 - viewHeight = viewWidth; + + } else if (mFitModel == FitModel.FM_WH_16X9) { + viewHeight = viewWidth * 9 / 16; + viewWidth = (int) (viewHeight * videoAspect); + } + else { + if (videoWidth > videoHeight) {//横屏视频 + //宽铺满,高度按比例 + viewHeight = (int) (viewWidth / videoAspect); + + } else if (videoWidth < videoHeight) {//竖屏视频 + //高铺满 宽自适应 + viewHeight = viewWidth; + viewWidth = (int) (viewHeight * videoAspect); + } else {//正方形视频 + viewHeight = viewWidth; + } } + } FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(viewWidth, viewHeight);