瀏覽代碼

优化视频播放器

yangchong 3 年之前
父節點
當前提交
e9bb07810e
共有 39 個文件被更改,包括 149 次插入150 次删除
  1. 1 1
      Demo/src/main/java/com/yc/ycvideoplayer/video/activity/NormalActivity.java
  2. 1 1
      Demo/src/main/java/com/yc/ycvideoplayer/video/ad/AdControlView.java
  3. 1 1
      Demo/src/main/java/com/yc/ycvideoplayer/video/danmu/MyDanmakuView.java
  4. 1 1
      Demo/src/main/java/com/yc/ycvideoplayer/video/list/PlayerMonitor.java
  5. 4 4
      Demo/src/main/java/com/yc/ycvideoplayer/video/tiktok/TikTokRenderView.java
  6. 2 2
      Demo/src/main/java/com/yc/ycvideoplayer/video/tiktok/TikTokRenderViewFactory.java
  7. 1 1
      Demo/src/main/java/com/yc/ycvideoplayer/video/tiktok/TikTokView.java
  8. 7 5
      ReadMeWiki/00.方案实践/03.播放器UI抽取封装.md
  9. 0 75
      ReadMeWiki/01.原理知识/02.视频播放器简单案例.md
  10. 2 2
      VideoPlayer/src/main/java/com/yc/video/bridge/ControlWrapper.java
  11. 4 2
      VideoPlayer/src/main/java/com/yc/video/controller/BaseVideoController.java
  12. 1 1
      VideoPlayer/src/main/java/com/yc/video/controller/GestureVideoController.java
  13. 1 1
      VideoPlayer/src/main/java/com/yc/video/controller/IGestureComponent.java
  14. 1 1
      VideoPlayer/src/main/java/com/yc/video/inter/IControlView.java
  15. 2 2
      VideoPlayer/src/main/java/com/yc/video/inter/ISurfaceView.java
  16. 1 1
      VideoPlayer/src/main/java/com/yc/video/inter/IVideoController.java
  17. 10 18
      VideoPlayer/src/main/java/com/yc/video/inter/IVideoPlayer.java
  18. 56 0
      VideoPlayer/src/main/java/com/yc/video/inter/IVideoPlayerScreen.java
  19. 1 3
      VideoPlayer/src/main/java/com/yc/video/inter/IViewController.java
  20. 1 1
      VideoPlayer/src/main/java/com/yc/video/inter/OnVideoStateListener.java
  21. 2 2
      VideoPlayer/src/main/java/com/yc/video/player/AudioFocusHelper.java
  22. 1 0
      VideoPlayer/src/main/java/com/yc/video/player/SimpleStateListener.java
  23. 23 8
      VideoPlayer/src/main/java/com/yc/video/player/VideoPlayer.java
  24. 2 2
      VideoPlayer/src/main/java/com/yc/video/surface/MeasureHelper.java
  25. 2 1
      VideoPlayer/src/main/java/com/yc/video/surface/RenderSurfaceView.java
  26. 2 1
      VideoPlayer/src/main/java/com/yc/video/surface/RenderTextureView.java
  27. 3 1
      VideoPlayer/src/main/java/com/yc/video/surface/SurfaceFactory.java
  28. 3 1
      VideoPlayer/src/main/java/com/yc/video/surface/SurfaceViewFactory.java
  29. 3 1
      VideoPlayer/src/main/java/com/yc/video/surface/TextureViewFactory.java
  30. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/more/CustomNetworkView.java
  31. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/more/CustomTrailersView.java
  32. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/pip/CustomFloatView.java
  33. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/view/CustomBottomView.java
  34. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/view/CustomCompleteView.java
  35. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/view/CustomErrorView.java
  36. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/view/CustomLiveControlView.java
  37. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/view/CustomOncePlayView.java
  38. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/view/CustomPrepareView.java
  39. 1 1
      VideoPlayer/src/main/java/com/yc/video/ui/view/CustomTitleView.java

+ 1 - 1
Demo/src/main/java/com/yc/ycvideoplayer/video/activity/NormalActivity.java

@@ -20,7 +20,7 @@ import com.yc.ycvideoplayer.ConstantVideo;
 import com.yc.ycvideoplayer.R;
 import com.yc.ycvideoplayer.R;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.VideoPlayerConfig;
 import com.yc.video.config.VideoPlayerConfig;
-import com.yc.video.player.OnVideoStateListener;
+import com.yc.video.inter.OnVideoStateListener;
 import com.yc.video.player.VideoPlayer;
 import com.yc.video.player.VideoPlayer;
 import com.yc.video.player.VideoPlayerBuilder;
 import com.yc.video.player.VideoPlayerBuilder;
 import com.yc.video.player.VideoViewManager;
 import com.yc.video.player.VideoViewManager;

+ 1 - 1
Demo/src/main/java/com/yc/ycvideoplayer/video/ad/AdControlView.java

@@ -17,7 +17,7 @@ import com.yc.ycvideoplayer.R;
 
 
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
 
 
 
 

+ 1 - 1
Demo/src/main/java/com/yc/ycvideoplayer/video/danmu/MyDanmakuView.java

@@ -21,7 +21,7 @@ import com.yc.ycvideoplayer.R;
 
 
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
 
 
 import master.flame.danmaku.controller.DrawHandler;
 import master.flame.danmaku.controller.DrawHandler;

+ 1 - 1
Demo/src/main/java/com/yc/ycvideoplayer/video/list/PlayerMonitor.java

@@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
 import com.yc.videotool.VideoLogUtils;
 import com.yc.videotool.VideoLogUtils;
 
 
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.bridge.ControlWrapper;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
 
 
 
 

+ 4 - 4
Demo/src/main/java/com/yc/ycvideoplayer/video/tiktok/TikTokRenderView.java

@@ -8,18 +8,18 @@ import androidx.annotation.NonNull;
 import com.yc.kernel.inter.AbstractVideoPlayer;
 import com.yc.kernel.inter.AbstractVideoPlayer;
 
 
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
-import com.yc.video.surface.InterSurfaceView;
+import com.yc.video.inter.ISurfaceView;
 
 
 
 
 /**
 /**
  * TikTok专用RenderView,横屏视频默认显示,竖屏视频居中裁剪
  * TikTok专用RenderView,横屏视频默认显示,竖屏视频居中裁剪
  * 使用代理模式实现
  * 使用代理模式实现
  */
  */
-public class TikTokRenderView implements InterSurfaceView {
+public class TikTokRenderView implements ISurfaceView {
 
 
-    private InterSurfaceView mProxyRenderView;
+    private ISurfaceView mProxyRenderView;
 
 
-    TikTokRenderView(@NonNull InterSurfaceView renderView) {
+    TikTokRenderView(@NonNull ISurfaceView renderView) {
         this.mProxyRenderView = renderView;
         this.mProxyRenderView = renderView;
     }
     }
 
 

+ 2 - 2
Demo/src/main/java/com/yc/ycvideoplayer/video/tiktok/TikTokRenderViewFactory.java

@@ -2,7 +2,7 @@ package com.yc.ycvideoplayer.video.tiktok;
 
 
 import android.content.Context;
 import android.content.Context;
 
 
-import com.yc.video.surface.InterSurfaceView;
+import com.yc.video.inter.ISurfaceView;
 import com.yc.video.surface.SurfaceFactory;
 import com.yc.video.surface.SurfaceFactory;
 import com.yc.video.surface.RenderTextureView;
 import com.yc.video.surface.RenderTextureView;
 
 
@@ -14,7 +14,7 @@ public class TikTokRenderViewFactory extends SurfaceFactory {
     }
     }
 
 
     @Override
     @Override
-    public InterSurfaceView createRenderView(Context context) {
+    public ISurfaceView createRenderView(Context context) {
         return new TikTokRenderView(new RenderTextureView(context));
         return new TikTokRenderView(new RenderTextureView(context));
     }
     }
 }
 }

+ 1 - 1
Demo/src/main/java/com/yc/ycvideoplayer/video/tiktok/TikTokView.java

@@ -20,7 +20,7 @@ import com.yc.ycvideoplayer.R;
 
 
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 public class TikTokView extends FrameLayout implements IControlView {
 public class TikTokView extends FrameLayout implements IControlView {
 
 

+ 7 - 5
ReadMeWiki/00.方案实践/03.播放器UI抽取封装.md

@@ -57,10 +57,16 @@
 
 
 ### 02.播放器UI封装目标
 ### 02.播放器UI封装目标
 #### 2.1 方便自定义
 #### 2.1 方便自定义
+- 把视频状态View当作Component
+    - Component 是组件的意思。这里充分利用了组件化思想,把一个个状态视频view当作一个个组件。避免把所有的视图都放到一起去写,避免代码臃肿。
 
 
 
 
 #### 2.2 和业务解藕
 #### 2.2 和业务解藕
-- 一定要解耦合。播放器player与视频UI解耦:支持添加自定义视频视图,比如支持添加自定义广告,新手引导,或者视频播放异常等视图,这个需要较强的拓展性
+- 一定要解耦合
+    - 播放器player与视频UI解耦:支持添加自定义视频视图,比如支持添加自定义广告,新手引导,或者视频播放异常等视图,这个需要较强的拓展性。
+- 业务和视频解耦合
+    - 视频缓存,给视频设置封面,视频播放完成后的操作。这些逻辑,不能写到视频播放器里面,可以暴露给外部开发者设置,必须和业务解耦合。
+    
 
 
 
 
 #### 2.3 使用简单
 #### 2.3 使用简单
@@ -408,10 +414,6 @@
 
 
 
 
 
 
-
-
-
-
 
 
 
 
 
 

+ 0 - 75
ReadMeWiki/01.原理知识/02.视频播放器简单案例.md

@@ -1,75 +0,0 @@
-# 13.视频播放器如何选择
-#### 目录介绍
-- 01.Android原生VideoView
-- 02.Google的ExoPlayer
-- 03.Vitamio视频播放框架
-- 04.B站的框架ijkplayer
-- 05.腾讯视频播放器框架
-
-
-### 01.Android原生VideoView
-
-
-
-
-### 02.Google的ExoPlayer
-- 根据自己的需求选择性添加依赖,如核心库和UI库,这两个可以满足基本上的视频播放需求:
-    ``` java
-    implementation 'com.google.android.exoplayer:exoplayer-core:2.X.X'
-    implementation 'com.google.android.exoplayer:exoplayer-ui:2.X.X'
-    ```
-- 整个ExoPlayer库包含5个字库,依赖5个子库和依赖整个库效果是一样的。
-    ``` java
-    exoplayer-core:核心功能 (必要)
-    exoplayer-dash:支持DASH内容
-    exoplayer-hls:支持HLS内容
-    exoplayer-smoothstreaming:支持SmoothStreaming内容
-    exoplayer-ui:用于ExoPlayer的UI组件和相关的资源。
-    ```
-- 在布局中引用代码
-    ``` java
-    <com.google.android.exoplayer2.ui.PlayerView
-       android:id="@+id/video_view"
-       android:layout_width="match_parent"
-       android:layout_height="match_parent"/>
-    ```
-- 代码如何使用,超级简单
-    ``` java
-    SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(this,
-            new DefaultTrackSelector(),new DefaultLoadControl());
-    player.setPlayWhenReady(true);
-    mVideoView.setPlayer(player);
-    Uri uri = Uri.parse(ConstantVideo.VideoPlayerList[0]);
-    DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("user-agent");
-    ProgressiveMediaSource mediaSource = new ProgressiveMediaSource.Factory(
-            dataSourceFactory).createMediaSource(uri);
-    // 播放
-    player.prepare(mediaSource);
-    ```
-
-
-
-
-### 03.Vitamio视频播放框架
-
-
-### 04.B站的框架ijkplayer
-
-
-
-
-### 05.腾讯视频播放器框架
-
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 2 - 2
VideoPlayer/src/main/java/com/yc/video/bridge/ControlWrapper.java

@@ -19,8 +19,8 @@ import android.app.Activity;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ActivityInfo;
 import android.graphics.Bitmap;
 import android.graphics.Bitmap;
 import androidx.annotation.NonNull;
 import androidx.annotation.NonNull;
-import com.yc.video.controller.IVideoController;
-import com.yc.video.player.IVideoPlayer;
+import com.yc.video.inter.IVideoController;
+import com.yc.video.inter.IVideoPlayer;
 
 
 
 
 /**
 /**

+ 4 - 2
VideoPlayer/src/main/java/com/yc/video/controller/BaseVideoController.java

@@ -33,13 +33,15 @@ import androidx.annotation.Nullable;
 
 
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
-import com.yc.video.player.IVideoPlayer;
+import com.yc.video.inter.IVideoController;
+import com.yc.video.inter.IViewController;
+import com.yc.video.inter.IVideoPlayer;
 import com.yc.video.player.VideoViewManager;
 import com.yc.video.player.VideoViewManager;
 import com.yc.video.player.VideoPlayer;
 import com.yc.video.player.VideoPlayer;
 import com.yc.video.tool.StatesCutoutUtils;
 import com.yc.video.tool.StatesCutoutUtils;
 import com.yc.video.tool.NetworkUtils;
 import com.yc.video.tool.NetworkUtils;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 import com.yc.videotool.VideoLogUtils;
 import com.yc.videotool.VideoLogUtils;
 
 

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/controller/GestureVideoController.java

@@ -31,7 +31,7 @@ import androidx.annotation.Nullable;
 import com.yc.videotool.VideoLogUtils;
 import com.yc.videotool.VideoLogUtils;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 import java.util.Map;
 import java.util.Map;
 
 

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/controller/IGestureComponent.java

@@ -15,7 +15,7 @@ limitations under the License.
 */
 */
 package com.yc.video.controller;
 package com.yc.video.controller;
 
 
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/inter/IControlView.java → VideoPlayer/src/main/java/com/yc/video/inter/IControlView.java

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 See the License for the specific language governing permissions and
 limitations under the License.
 limitations under the License.
 */
 */
-package com.yc.video.ui.inter;
+package com.yc.video.inter;
 
 
 import android.view.View;
 import android.view.View;
 import android.view.animation.Animation;
 import android.view.animation.Animation;

+ 2 - 2
VideoPlayer/src/main/java/com/yc/video/surface/InterSurfaceView.java → VideoPlayer/src/main/java/com/yc/video/inter/ISurfaceView.java

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 See the License for the specific language governing permissions and
 limitations under the License.
 limitations under the License.
 */
 */
-package com.yc.video.surface;
+package com.yc.video.inter;
 
 
 import android.graphics.Bitmap;
 import android.graphics.Bitmap;
 import android.view.View;
 import android.view.View;
@@ -31,7 +31,7 @@ import com.yc.kernel.inter.AbstractVideoPlayer;
  *     revise:
  *     revise:
  * </pre>
  * </pre>
  */
  */
-public interface InterSurfaceView {
+public interface ISurfaceView {
 
 
     /**
     /**
      * 关联AbstractPlayer
      * 关联AbstractPlayer

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/controller/IVideoController.java → VideoPlayer/src/main/java/com/yc/video/inter/IVideoController.java

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 See the License for the specific language governing permissions and
 limitations under the License.
 limitations under the License.
 */
 */
-package com.yc.video.controller;
+package com.yc.video.inter;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 10 - 18
VideoPlayer/src/main/java/com/yc/video/player/IVideoPlayer.java → VideoPlayer/src/main/java/com/yc/video/inter/IVideoPlayer.java

@@ -28,7 +28,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 See the License for the specific language governing permissions and
 limitations under the License.
 limitations under the License.
 */
 */
-package com.yc.video.player;
+package com.yc.video.inter;
 
 
 import android.graphics.Bitmap;
 import android.graphics.Bitmap;
 
 
@@ -43,7 +43,7 @@ import com.yc.video.config.ConstantKeys;
  *     revise: 播放器基础属性获取和设置属性接口
  *     revise: 播放器基础属性获取和设置属性接口
  * </pre>
  * </pre>
  */
  */
-public interface IVideoPlayer {
+public interface IVideoPlayer extends IVideoPlayerScreen{
 
 
     /**
     /**
      * 设置链接
      * 设置链接
@@ -73,7 +73,6 @@ public interface IVideoPlayer {
      */
      */
     long getDuration();
     long getDuration();
 
 
-
     /**
     /**
      * 获取当前播放的位置
      * 获取当前播放的位置
      * @return                              long类型
      * @return                              long类型
@@ -98,15 +97,16 @@ public interface IVideoPlayer {
      */
      */
     int getBufferedPercentage();
     int getBufferedPercentage();
 
 
-
-    void startFullScreen();
-
-    void stopFullScreen();
-
-    boolean isFullScreen();
-
+    /**
+     * 设置是否静音
+     * @param isMute                        是否静音
+     */
     void setMute(boolean isMute);
     void setMute(boolean isMute);
 
 
+    /**
+     * 是否静音
+     * @return                              布尔值
+     */
     boolean isMute();
     boolean isMute();
 
 
     void setScreenScaleType(@ConstantKeys.ScreenScaleType int screenScaleType);
     void setScreenScaleType(@ConstantKeys.ScreenScaleType int screenScaleType);
@@ -121,16 +121,8 @@ public interface IVideoPlayer {
 
 
     void setMirrorRotation(boolean enable);
     void setMirrorRotation(boolean enable);
 
 
-    Bitmap doScreenShot();
-
     int[] getVideoSize();
     int[] getVideoSize();
 
 
     void setRotation(float rotation);
     void setRotation(float rotation);
 
 
-    void startTinyScreen();
-
-    void stopTinyScreen();
-
-    boolean isTinyScreen();
-
 }
 }

+ 56 - 0
VideoPlayer/src/main/java/com/yc/video/inter/IVideoPlayerScreen.java

@@ -0,0 +1,56 @@
+package com.yc.video.inter;
+
+import android.graphics.Bitmap;
+
+/**
+ * <pre>
+ *     @author yangchong
+ *     blog  : https://github.com/yangchong211
+ *     time  : 2017/11/21
+ *     desc  : VideoPlayer屏幕相关接口
+ *     revise:
+ * </pre>
+ */
+public interface IVideoPlayerScreen {
+
+    /**
+     * 屏幕截图
+     * @return                              返回bitmap对象
+     */
+    Bitmap doScreenShot();
+
+
+    /**
+     * 开启全屏幕展示
+     */
+    void startFullScreen();
+
+    /**
+     * 关闭全屏幕展示
+     */
+    void stopFullScreen();
+
+    /**
+     * 判断是否全屏幕展示
+     * @return                              布尔
+     */
+    boolean isFullScreen();
+
+    /**
+     * 开启小屏幕展示
+     */
+    void startTinyScreen();
+
+    /**
+     * 关闭小屏幕展示
+     */
+    void stopTinyScreen();
+
+    /**
+     * 判断是否小屏幕
+     * @return                              布尔
+     */
+    boolean isTinyScreen();
+
+
+}

+ 1 - 3
VideoPlayer/src/main/java/com/yc/video/controller/IViewController.java → VideoPlayer/src/main/java/com/yc/video/inter/IViewController.java

@@ -13,9 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 See the License for the specific language governing permissions and
 limitations under the License.
 limitations under the License.
 */
 */
-package com.yc.video.controller;
-
-import com.yc.video.ui.inter.IControlView;
+package com.yc.video.inter;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/player/OnVideoStateListener.java → VideoPlayer/src/main/java/com/yc/video/inter/OnVideoStateListener.java

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 See the License for the specific language governing permissions and
 limitations under the License.
 limitations under the License.
 */
 */
-package com.yc.video.player;
+package com.yc.video.inter;
 
 
 
 
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;

+ 2 - 2
VideoPlayer/src/main/java/com/yc/video/player/AudioFocusHelper.java

@@ -36,8 +36,8 @@ import java.lang.ref.WeakReference;
 public final class AudioFocusHelper implements AudioManager.OnAudioFocusChangeListener {
 public final class AudioFocusHelper implements AudioManager.OnAudioFocusChangeListener {
 
 
     private Handler mHandler = new Handler(Looper.getMainLooper());
     private Handler mHandler = new Handler(Looper.getMainLooper());
-    private WeakReference<VideoPlayer> mWeakVideoView;
-    private AudioManager mAudioManager;
+    private final WeakReference<VideoPlayer> mWeakVideoView;
+    private final AudioManager mAudioManager;
     private boolean mStartRequested = false;
     private boolean mStartRequested = false;
     private boolean mPausedForLoss = false;
     private boolean mPausedForLoss = false;
     private int mCurrentFocus = 0;
     private int mCurrentFocus = 0;

+ 1 - 0
VideoPlayer/src/main/java/com/yc/video/player/SimpleStateListener.java

@@ -16,6 +16,7 @@ limitations under the License.
 package com.yc.video.player;
 package com.yc.video.player;
 
 
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
+import com.yc.video.inter.OnVideoStateListener;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 23 - 8
VideoPlayer/src/main/java/com/yc/video/player/VideoPlayer.java

@@ -34,7 +34,9 @@ import com.yc.video.config.VideoPlayerConfig;
 import com.yc.video.controller.BaseVideoController;
 import com.yc.video.controller.BaseVideoController;
 import com.yc.kernel.inter.AbstractVideoPlayer;
 import com.yc.kernel.inter.AbstractVideoPlayer;
 import com.yc.kernel.factory.PlayerFactory;
 import com.yc.kernel.factory.PlayerFactory;
-import com.yc.video.surface.InterSurfaceView;
+import com.yc.video.inter.ISurfaceView;
+import com.yc.video.inter.IVideoPlayer;
+import com.yc.video.inter.OnVideoStateListener;
 import com.yc.video.surface.SurfaceFactory;
 import com.yc.video.surface.SurfaceFactory;
 import com.yc.video.tool.BaseToast;
 import com.yc.video.tool.BaseToast;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
@@ -78,16 +80,26 @@ public class VideoPlayer<P extends AbstractVideoPlayer> extends FrameLayout
      * 真正承载播放器视图的容器
      * 真正承载播放器视图的容器
      */
      */
     protected FrameLayout mPlayerContainer;
     protected FrameLayout mPlayerContainer;
-
-    protected InterSurfaceView mRenderView;
+    /**
+     * 这个是渲染view对象
+     */
+    protected ISurfaceView mRenderView;
+    /**
+     * 渲染View创建的工厂类对象
+     */
     protected SurfaceFactory mRenderViewFactory;
     protected SurfaceFactory mRenderViewFactory;
+    /**
+     * 当前视频设置的比例
+     */
     protected int mCurrentScreenScaleType;
     protected int mCurrentScreenScaleType;
+    /**
+     * 视频的大小
+     */
     protected int[] mVideoSize = {0, 0};
     protected int[] mVideoSize = {0, 0};
     /**
     /**
      * 是否静音
      * 是否静音
      */
      */
     protected boolean mIsMute;
     protected boolean mIsMute;
-
     /**
     /**
      * 当前播放视频的地址
      * 当前播放视频的地址
      */
      */
@@ -127,25 +139,24 @@ public class VideoPlayer<P extends AbstractVideoPlayer> extends FrameLayout
      * 监听系统中音频焦点改变
      * 监听系统中音频焦点改变
      */
      */
     protected boolean mEnableAudioFocus;
     protected boolean mEnableAudioFocus;
+    /**
+     * 音频焦点改变监听的帮助类
+     */
     @Nullable
     @Nullable
     protected AudioFocusHelper mAudioFocusHelper;
     protected AudioFocusHelper mAudioFocusHelper;
-
     /**
     /**
      * OnStateChangeListener集合,保存了所有开发者设置的监听器
      * OnStateChangeListener集合,保存了所有开发者设置的监听器
      */
      */
     protected List<OnVideoStateListener> mOnStateChangeListeners;
     protected List<OnVideoStateListener> mOnStateChangeListeners;
-
     /**
     /**
      * 进度管理器,设置之后播放器会记录播放进度,以便下次播放恢复进度
      * 进度管理器,设置之后播放器会记录播放进度,以便下次播放恢复进度
      */
      */
     @Nullable
     @Nullable
     protected ProgressManager mProgressManager;
     protected ProgressManager mProgressManager;
-
     /**
     /**
      * 循环播放
      * 循环播放
      */
      */
     protected boolean mIsLooping;
     protected boolean mIsLooping;
-
     /**
     /**
      * {@link #mPlayerContainer}背景色,默认黑色
      * {@link #mPlayerContainer}背景色,默认黑色
      */
      */
@@ -171,9 +182,13 @@ public class VideoPlayer<P extends AbstractVideoPlayer> extends FrameLayout
         initConfig();
         initConfig();
         //读取xml中的配置,并综合全局配置
         //读取xml中的配置,并综合全局配置
         initAttrs(attrs);
         initAttrs(attrs);
+        //初始化view
         initView();
         initView();
     }
     }
 
 
+    /**
+     * 读取初始化配置数据
+     */
     private void initConfig() {
     private void initConfig() {
         VideoPlayerConfig config = VideoViewManager.getConfig();
         VideoPlayerConfig config = VideoViewManager.getConfig();
         mEnableAudioFocus = config.mEnableAudioFocus;
         mEnableAudioFocus = config.mEnableAudioFocus;

+ 2 - 2
VideoPlayer/src/main/java/com/yc/video/surface/MeasureHelper.java

@@ -28,7 +28,7 @@ import com.yc.video.config.ConstantKeys;
  *     revise:
  *     revise:
  * </pre>
  * </pre>
  */
  */
-public class MeasureHelper {
+public final class MeasureHelper {
 
 
     private int mVideoWidth;
     private int mVideoWidth;
     private int mVideoHeight;
     private int mVideoHeight;
@@ -53,7 +53,7 @@ public class MeasureHelper {
         mVideoHeight = height;
         mVideoHeight = height;
     }
     }
 
 
-    public void setScreenScale(int screenScale) {
+    public void setScreenScale(@ConstantKeys.ScreenScaleType int screenScale) {
         mCurrentScreenScale = screenScale;
         mCurrentScreenScale = screenScale;
     }
     }
 
 

+ 2 - 1
VideoPlayer/src/main/java/com/yc/video/surface/RenderSurfaceView.java

@@ -27,6 +27,7 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.Nullable;
 
 
 import com.yc.kernel.inter.AbstractVideoPlayer;
 import com.yc.kernel.inter.AbstractVideoPlayer;
+import com.yc.video.inter.ISurfaceView;
 
 
 /**
 /**
  * <pre>
  * <pre>
@@ -37,7 +38,7 @@ import com.yc.kernel.inter.AbstractVideoPlayer;
  *     revise:
  *     revise:
  * </pre>
  * </pre>
  */
  */
-public class RenderSurfaceView extends SurfaceView implements InterSurfaceView {
+public class RenderSurfaceView extends SurfaceView implements ISurfaceView {
 
 
     /**
     /**
      * 优点:可以在一个独立的线程中进行绘制,不会影响主线程;使用双缓冲机制,播放视频时画面更流畅
      * 优点:可以在一个独立的线程中进行绘制,不会影响主线程;使用双缓冲机制,播放视频时画面更流畅

+ 2 - 1
VideoPlayer/src/main/java/com/yc/video/surface/RenderTextureView.java

@@ -27,6 +27,7 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.Nullable;
 
 
 import com.yc.kernel.inter.AbstractVideoPlayer;
 import com.yc.kernel.inter.AbstractVideoPlayer;
+import com.yc.video.inter.ISurfaceView;
 
 
 
 
 /**
 /**
@@ -40,7 +41,7 @@ import com.yc.kernel.inter.AbstractVideoPlayer;
  * </pre>
  * </pre>
  */
  */
 @SuppressLint("ViewConstructor")
 @SuppressLint("ViewConstructor")
-public class RenderTextureView extends TextureView implements InterSurfaceView {
+public class RenderTextureView extends TextureView implements ISurfaceView {
 
 
     private MeasureHelper mMeasureHelper;
     private MeasureHelper mMeasureHelper;
     private SurfaceTexture mSurfaceTexture;
     private SurfaceTexture mSurfaceTexture;

+ 3 - 1
VideoPlayer/src/main/java/com/yc/video/surface/SurfaceFactory.java

@@ -17,6 +17,8 @@ package com.yc.video.surface;
 
 
 import android.content.Context;
 import android.content.Context;
 
 
+import com.yc.video.inter.ISurfaceView;
+
 /**
 /**
  * <pre>
  * <pre>
  *     @author yangchong
  *     @author yangchong
@@ -28,6 +30,6 @@ import android.content.Context;
  */
  */
 public abstract class SurfaceFactory {
 public abstract class SurfaceFactory {
 
 
-    public abstract InterSurfaceView createRenderView(Context context);
+    public abstract ISurfaceView createRenderView(Context context);
 
 
 }
 }

+ 3 - 1
VideoPlayer/src/main/java/com/yc/video/surface/SurfaceViewFactory.java

@@ -17,6 +17,8 @@ package com.yc.video.surface;
 
 
 import android.content.Context;
 import android.content.Context;
 
 
+import com.yc.video.inter.ISurfaceView;
+
 /**
 /**
  * <pre>
  * <pre>
  *     @author yangchong
  *     @author yangchong
@@ -33,7 +35,7 @@ public class SurfaceViewFactory extends SurfaceFactory {
     }
     }
 
 
     @Override
     @Override
-    public InterSurfaceView createRenderView(Context context) {
+    public ISurfaceView createRenderView(Context context) {
         //创建SurfaceView
         //创建SurfaceView
         return new RenderSurfaceView(context);
         return new RenderSurfaceView(context);
     }
     }

+ 3 - 1
VideoPlayer/src/main/java/com/yc/video/surface/TextureViewFactory.java

@@ -2,6 +2,8 @@ package com.yc.video.surface;
 
 
 import android.content.Context;
 import android.content.Context;
 
 
+import com.yc.video.inter.ISurfaceView;
+
 /**
 /**
  * <pre>
  * <pre>
  *     @author yangchong
  *     @author yangchong
@@ -18,7 +20,7 @@ public class TextureViewFactory extends SurfaceFactory {
     }
     }
 
 
     @Override
     @Override
-    public InterSurfaceView createRenderView(Context context) {
+    public ISurfaceView createRenderView(Context context) {
         //创建TextureView
         //创建TextureView
         return new RenderTextureView(context);
         return new RenderTextureView(context);
     }
     }

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/more/CustomNetworkView.java

@@ -25,7 +25,7 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.Nullable;
 
 
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.bridge.ControlWrapper;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/more/CustomTrailersView.java

@@ -25,7 +25,7 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.Nullable;
 
 
 import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.bridge.ControlWrapper;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/pip/CustomFloatView.java

@@ -34,7 +34,7 @@ import com.yc.video.bridge.ControlWrapper;
 
 
 import com.yc.video.R;
 import com.yc.video.R;
 
 
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/view/CustomBottomView.java

@@ -43,7 +43,7 @@ import com.yc.video.config.VideoPlayerConfig;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
 
 
 import com.yc.video.R;
 import com.yc.video.R;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 /**
 /**
  * <pre>
  * <pre>

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/view/CustomCompleteView.java

@@ -35,7 +35,7 @@ import com.yc.video.tool.BaseToast;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
 
 
 import com.yc.video.R;
 import com.yc.video.R;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 
 
 /**
 /**

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/view/CustomErrorView.java

@@ -36,7 +36,7 @@ import com.yc.video.bridge.ControlWrapper;
 
 
 import com.yc.video.R;
 import com.yc.video.R;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 
 
 /**
 /**

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/view/CustomLiveControlView.java

@@ -33,7 +33,7 @@ import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
 
 
 import com.yc.video.R;
 import com.yc.video.R;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 
 
 /**
 /**

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/view/CustomOncePlayView.java

@@ -33,7 +33,7 @@ import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.config.ConstantKeys;
 import com.yc.video.tool.BaseToast;
 import com.yc.video.tool.BaseToast;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 
 
 /**
 /**

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/view/CustomPrepareView.java

@@ -33,7 +33,7 @@ import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.player.VideoViewManager;
 import com.yc.video.player.VideoViewManager;
 
 
 import com.yc.video.R;
 import com.yc.video.R;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 
 
 /**
 /**

+ 1 - 1
VideoPlayer/src/main/java/com/yc/video/ui/view/CustomTitleView.java

@@ -38,7 +38,7 @@ import com.yc.video.bridge.ControlWrapper;
 import com.yc.video.tool.PlayerUtils;
 import com.yc.video.tool.PlayerUtils;
 
 
 import com.yc.video.R;
 import com.yc.video.R;
-import com.yc.video.ui.inter.IControlView;
+import com.yc.video.inter.IControlView;
 
 
 
 
 /**
 /**