Răsfoiți Sursa

完善原生demo

杨充 4 ani în urmă
părinte
comite
1da67e7fdd

+ 9 - 4
VideoPlayer/src/main/java/org/yczbj/ycvideoplayerlib/surface/MeasureHelper.java

@@ -8,11 +8,8 @@ import org.yczbj.ycvideoplayerlib.config.ConstantKeys;
 public class MeasureHelper {
 
     private int mVideoWidth;
-
     private int mVideoHeight;
-
     private int mCurrentScreenScale;
-
     private int mVideoRotationDegree;
 
     public void setVideoRotation(int videoRotationDegree) {
@@ -30,9 +27,11 @@ public class MeasureHelper {
 
     /**
      * 注意:VideoView的宽高一定要定死,否者以下算法不成立
+     * 借鉴于网络
      */
     public int[] doMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        if (mVideoRotationDegree == 90 || mVideoRotationDegree == 270) { // 软解码时处理旋转信息,交换宽高
+        if (mVideoRotationDegree == 90 || mVideoRotationDegree == 270) {
+            // 软解码时处理旋转信息,交换宽高
             widthMeasureSpec = widthMeasureSpec + heightMeasureSpec;
             heightMeasureSpec = widthMeasureSpec - heightMeasureSpec;
             widthMeasureSpec = widthMeasureSpec - heightMeasureSpec;
@@ -47,6 +46,7 @@ public class MeasureHelper {
 
         //如果设置了比例
         switch (mCurrentScreenScale) {
+            //默认正常类型
             case ConstantKeys.PlayerScreenScaleType.SCREEN_SCALE_DEFAULT:
             default:
                 if (mVideoWidth * height < width * mVideoHeight) {
@@ -55,10 +55,12 @@ public class MeasureHelper {
                     height = width * mVideoHeight / mVideoWidth;
                 }
                 break;
+            //原始类型,指视频的原始类型
             case ConstantKeys.PlayerScreenScaleType.SCREEN_SCALE_ORIGINAL:
                 width = mVideoWidth;
                 height = mVideoHeight;
                 break;
+            //16:9比例类型,最为常见
             case ConstantKeys.PlayerScreenScaleType.SCREEN_SCALE_16_9:
                 if (height > width / 16 * 9) {
                     height = width / 16 * 9;
@@ -66,6 +68,7 @@ public class MeasureHelper {
                     width = height / 9 * 16;
                 }
                 break;
+            //4:3比例类型,也比较常见
             case ConstantKeys.PlayerScreenScaleType.SCREEN_SCALE_4_3:
                 if (height > width / 4 * 3) {
                     height = width / 4 * 3;
@@ -73,10 +76,12 @@ public class MeasureHelper {
                     width = height / 3 * 4;
                 }
                 break;
+            //充满整个控件视图
             case ConstantKeys.PlayerScreenScaleType.SCREEN_SCALE_MATCH_PARENT:
                 width = widthMeasureSpec;
                 height = heightMeasureSpec;
                 break;
+            //剧中裁剪类型
             case ConstantKeys.PlayerScreenScaleType.SCREEN_SCALE_CENTER_CROP:
                 if (mVideoWidth * height > width * mVideoHeight) {
                     width = height * mVideoWidth / mVideoHeight;

BIN
image/111602569651_.pic.jpg


BIN
image/121602569652_.pic.jpg


BIN
image/131602569653_.pic.jpg


BIN
image/141602569654_.pic.jpg


BIN
image/151602569655_.pic.jpg


BIN
image/161602569656_.pic.jpg


+ 8 - 0
read/01.视频播放器介绍文档.md

@@ -334,6 +334,14 @@
 
 
 ### 10.播放器问题记录说明
+- 关于如何调整视频的播放填充类型。在该库中提供了6中不同类型供你选择,即正常默认类型;16:9类型,4:3类型;充满整个控件视图;剧中裁剪类型等类型,就是模仿了图片设置缩放的方式。其实这个就是设置SurfaceView的宽高……
+    - 这里播放正常视频建议选择16:9类型的,缩放后会有留黑;针对类似快手抖音视频,一个页面一个视频建议选择充满整个控件视图,会裁剪但是会铺满视频。
+- 关于前后台切换视频问题
+    - 从前台切到后台,当视频正在播放或者正在缓冲时,调用该方法暂停视频。
+    - 从后台切换到前台,当视频暂停时或者缓冲暂停时,调用该方法重新开启视频播放。也可以让用户手动去点击播放视频。
+- 播放器在正常播放和全屏模式切换状态栏问题
+    - 待完善,需要处理刘海
+
 
 
 ### 11.性能优化和库大小