1. 原理

不直接改变Codec输出的视频宽高比,而是改变视频播放器窗体的大小。



2. 设置Window

须要将Window设置未能够超出屏幕尺寸

mWindow.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);


3. SurfaceView保持宽高比

mSurfaceHolder.setFixedSize(mVideoWidth, mVideoHeight);


4. 改变Surface窗体大小

ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) mSurface.getLayoutParams();
if (scale > 4.0f) {
    scale = 4.0f;
} else if (scale < 0.25f) {
    scale = 0.25f;
}
layoutParams.width = (int) (windowWidth * scale);
layoutParams.height = (int) (windowHeight * scale);

mSurface.setLayoutParams(layoutParams);




相关文章:

  • 2021-04-06
  • 2021-11-17
  • 2022-01-10
  • 2021-07-05
  • 2021-05-22
  • 2021-10-18
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
相关资源
相似解决方案