|
@@ -734,23 +734,33 @@ public class MusicHandleActivity extends BaseMVPActivity<AcMusicHandleLayoutBind
|
|
|
private void resetVideoSize(int width, int height) {
|
|
|
int surfaceWidth = viewBinding.flSurface.getWidth();
|
|
|
int surfaceHeight = viewBinding.flSurface.getHeight();
|
|
|
- LOG.i("pq", "surfaceWidth:" + surfaceWidth);
|
|
|
- LOG.i("pq", "surfaceHeight:" + surfaceHeight);
|
|
|
- float percent = surfaceWidth * 1.0f / surfaceHeight;
|
|
|
- float percent2 = width * 1.0f / height;
|
|
|
- LOG.i("pq", "percent:" + percent);
|
|
|
- LOG.i("pq", "percent2:" + percent2);
|
|
|
- boolean b = NumberUtils.compareResult(percent, percent2);
|
|
|
- LOG.i("pq", "compareResult:" + b);
|
|
|
+ LOG.i("resetVideoSize", "surfaceWidth:" + surfaceWidth);
|
|
|
+ LOG.i("resetVideoSize", "surfaceHeight:" + surfaceHeight);
|
|
|
+ float containerAspectRatio = surfaceWidth * 1.0f / surfaceHeight;
|
|
|
+ float videoAspectRatio = width * 1.0f / height;
|
|
|
+ LOG.i("resetVideoSize", "containerAspectRatio:" + containerAspectRatio);
|
|
|
+ LOG.i("resetVideoSize", "videoAspectRatio:" + videoAspectRatio);
|
|
|
+ boolean b = NumberUtils.compareResult(containerAspectRatio, videoAspectRatio);
|
|
|
+ LOG.i("resetVideoSize", "compareResult:" + b);
|
|
|
if (b) {
|
|
|
return;
|
|
|
}
|
|
|
- LOG.i("pq", "videoWidth:" + width);
|
|
|
- LOG.i("pq", "videoHeight:" + height);
|
|
|
- int w = surfaceWidth;
|
|
|
- int h = (int) ((surfaceWidth * 1.0f / width) * height);
|
|
|
- LOG.i("pq", "w:" + w);
|
|
|
- LOG.i("pq", "h:" + h);
|
|
|
+ LOG.i("resetVideoSize", "videoWidth:" + width);
|
|
|
+ LOG.i("resetVideoSize", "videoHeight:" + height);
|
|
|
+ int w;
|
|
|
+ int h;
|
|
|
+ if (containerAspectRatio > videoAspectRatio) {
|
|
|
+ // 容器更宽,视频高度适应容器高度
|
|
|
+ h = surfaceHeight;
|
|
|
+ w = (int) (surfaceHeight * videoAspectRatio);
|
|
|
+ } else {
|
|
|
+ // 容器更高,视频宽度适应容器宽度
|
|
|
+ w = surfaceWidth;
|
|
|
+ h = (int) (surfaceWidth / videoAspectRatio);
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG.i("resetVideoSize", "w:" + w);
|
|
|
+ LOG.i("resetVideoSize", "h:" + h);
|
|
|
if (w > surfaceWidth) {
|
|
|
w = surfaceWidth;
|
|
|
}
|