Browse Source

完善文档

杨充 4 years ago
parent
commit
b9f12c555b

+ 4 - 2
Demo/src/main/java/com/yc/ycvideoplayer/BuriedPointEventImpl.java

@@ -1,10 +1,10 @@
 package com.yc.ycvideoplayer;
 
-import android.location.LocationManager;
-
 import com.yc.kernel.utils.VideoLogUtils;
 
 import com.yc.video.config.BuriedPointEvent;
+import com.yc.videosqllite.manager.LocationManager;
+import com.yc.videosqllite.model.VideoLocation;
 
 public class BuriedPointEventImpl implements BuriedPointEvent {
 
@@ -82,6 +82,8 @@ public class BuriedPointEventImpl implements BuriedPointEvent {
     @Override
     public void playerOutProgress(String url, long duration, long currentPosition) {
         VideoLogUtils.i("BuriedPointEvent---退出视频播放时候的播放进度百度比--"+url+"-----"+duration+"----"+currentPosition);
+        VideoLocation location = new VideoLocation(url,currentPosition,duration);
+        LocationManager.getInstance().put(url,location);
     }
 
     /**

+ 9 - 3
README.md

@@ -53,10 +53,11 @@
 |**视频播放位置本地记录**| 支持  |支持   |支持   |   |   |
 
 
+
 ### 02.视频播放器功能
 |**类型** | 功能说明 |
 |--------   |-----        |
-|**项目结构** | VideoCache缓存lib,VideoKernel视频内核lib,VideoPlayer视频UIlib |
+|**项目结构** | VideoCache缓存lib,VideoKernel视频内核lib,VideoPlayer视频UI等lib , VideoSqlLite视频位置二级缓存, VideoView视频悬浮lib , VideoM3u8下载m3u8以及合成库lib |
 |**内核** | MediaPlayer、ExoPlayer、IjkPlayer,后期接入Rtc和TXPlayer |
 |**协议/格式** | http/https、concat、rtsp、hls、rtmp、file、m3u8、mkv、webm、mp3、mp4等 |
 |**画面** | 调整显示比例:默认、16:9、4:3、填充;播放时旋转画面角度(0,90,180,270);镜像旋转 |
@@ -67,6 +68,7 @@
 |**视频播放位置本地记录** | 本地可以记录播放视频的播放位置,采用二级缓存模式:内存缓存 + 磁盘缓存 + key缓存 + 配置缓存大小和类型和路径|
 
 
+
 ### 03.视频播放器结构说明
 #### 3.1 视频播放器架构图
 ![image](https://img-blog.csdnimg.cn/20201016173604612.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzM3NzAwMjc1,size_16,color_FFFFFF,t_70#pic_center)
@@ -129,6 +131,8 @@
     implementation 'cn.yc:VideoCache:3.0.5'
     //视频内核层,必须有
     implementation 'cn.yc:VideoKernel:3.0.6'
+    //视频播放器播放位置记录,选择性添加
+    implementation 'cn.yc:VideoSqlLite:1.0.2'
     ```
 
 #### 4.2 在xml中添加布局
@@ -177,9 +181,11 @@
 
 
 #### 4.5 关于视频播放位置本地记录
+- 播放视频位置常见操作
+    - 最好是服务端记录播放位置……常见的视频播放器把播放位置保存到服务端,这样用户换了设备则也可以拉下数据,或者卸载再安装也可以拉下服务端播放位置数据。
 - 为何有该需求
-    - 主要是公司开发多个定制平板教育app,由于服务端没有做视频播放位置存储功能,为完成任务最后采用本地记录视频播放位置。最好是服务端记录播放位置……
-- 如何做技术选型
+    - 主要是公司开发多个定制平板教育app,由于服务端没有做视频播放位置存储功能,而且教育类卖的是设备+教育app(launcher应用),更换设备可能性小,为完成任务最后采用本地记录视频播放位置。
+- **如何做技术选型**
     - 采用二级缓存,内存缓存和磁盘缓存。关于磁盘缓存,刚开始想着使用sql或者greenDao或者realm数据库,考虑到做成封装库,故要求体积小,尽量不依赖三方库还要效率高,因此磁盘缓存采用DiskLruCache。具体使用看api文档……
 
 

+ 1 - 0
VideoBarrage/.gitignore

@@ -0,0 +1 @@
+/build

+ 32 - 0
VideoBarrage/build.gradle

@@ -0,0 +1,32 @@
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion 29
+    buildToolsVersion "29.0.3"
+
+    defaultConfig {
+        minSdkVersion 17
+        targetSdkVersion 29
+        versionCode 1
+        versionName "1.0"
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        consumerProguardFiles "consumer-rules.pro"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    implementation fileTree(dir: "libs", include: ["*.jar"])
+    implementation 'androidx.appcompat:appcompat:1.2.0'
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+
+}

+ 0 - 0
VideoBarrage/consumer-rules.pro


+ 21 - 0
VideoBarrage/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 5 - 0
VideoBarrage/src/main/AndroidManifest.xml

@@ -0,0 +1,5 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.yc.videobarrage">
+
+    /
+</manifest>

+ 7 - 0
VideoBarrage/src/main/java/com/yc/videobarrage/Test.java

@@ -0,0 +1,7 @@
+package com.yc.videobarrage;
+
+public class Test {
+
+    //代码待提交,完善之后再开源
+
+}

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

@@ -168,6 +168,7 @@ public abstract class GestureVideoController extends BaseVideoController impleme
     @Override
     public boolean onSingleTapConfirmed(MotionEvent e) {
         if (isInPlaybackState()) {
+            //切换显示/隐藏状态
             mControlWrapper.toggleShowState();
         }
         return true;
@@ -178,7 +179,11 @@ public abstract class GestureVideoController extends BaseVideoController impleme
      */
     @Override
     public boolean onDoubleTap(MotionEvent e) {
-        if (!isLocked() && isInPlaybackState()) togglePlay();
+        //如果没有锁屏,
+        if (!isLocked() && isInPlaybackState()){
+            //播放和暂停
+            togglePlay();
+        }
         return true;
     }
 

+ 1 - 0
VideoRecorder/.gitignore

@@ -0,0 +1 @@
+/build

+ 32 - 0
VideoRecorder/build.gradle

@@ -0,0 +1,32 @@
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion 29
+    buildToolsVersion "29.0.3"
+
+    defaultConfig {
+        minSdkVersion 17
+        targetSdkVersion 29
+        versionCode 1
+        versionName "1.0"
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        consumerProguardFiles "consumer-rules.pro"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    implementation fileTree(dir: "libs", include: ["*.jar"])
+    implementation 'androidx.appcompat:appcompat:1.2.0'
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+
+}

+ 0 - 0
VideoRecorder/consumer-rules.pro


+ 21 - 0
VideoRecorder/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 5 - 0
VideoRecorder/src/main/AndroidManifest.xml

@@ -0,0 +1,5 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.yc.videorecorder">
+
+    /
+</manifest>

+ 7 - 0
VideoRecorder/src/main/java/com/yc/videorecorder/Test.java

@@ -0,0 +1,7 @@
+package com.yc.videorecorder;
+
+public class Test {
+
+    //代码待提交,完善之后再开源
+
+}

+ 7 - 0
VideoScreen/src/main/java/com/yc/videoscreen/Test.java

@@ -0,0 +1,7 @@
+package com.yc.videoscreen;
+
+public class Test {
+
+    //代码待提交,完善之后再开源
+
+}

+ 0 - 1
VideoSqlLite/src/main/java/com/yc/videosqllite/manager/LocationManager.java

@@ -34,7 +34,6 @@ public class LocationManager {
      * 7.如何一键将本地记录数据上传
      * 8.拓展性和封闭性
      * 9.性能,插入和获取数据,超1000条数据测试
-     * 10.将sql执行sql语句给简化,避免手写sql语句,因为特别容易出问题。而且存取bean如果比较复杂那很难搞
      */
 
     /**

+ 39 - 2
VideoSqlLite/src/main/java/com/yc/videosqllite/model/VideoLocation.java

@@ -19,7 +19,7 @@ import java.util.Objects;
  *     revise: 必须
  * </pre>
  */
-public class VideoLocation implements Serializable {
+public class VideoLocation implements Serializable , Cloneable{
 
     /**
      * 视频链接
@@ -158,6 +158,32 @@ public class VideoLocation implements Serializable {
         return hash(url,urlMd5,position,totalTime);
     }
 
+    /**
+     * 重写clone()方法
+     * 浅拷贝
+     * @return
+     */
+    public Object clone() {
+        //浅拷贝
+        try {
+            // 直接调用父类的clone()方法
+            return super.clone();
+        } catch (CloneNotSupportedException e) {
+            return null;
+        }
+    }
+
+    /**
+     * 重写clone()方法
+     * 深拷贝
+     * @return
+     */
+    public Object deepClone() {
+        // 深拷贝,创建拷贝类的一个新对象,这样就和原始对象相互独立
+        VideoLocation location = new VideoLocation(url,position,totalTime);
+        return location;
+    }
+
     /**
      * 比较两个对象
      * @param a                         a对象
@@ -176,6 +202,17 @@ public class VideoLocation implements Serializable {
      * @return
      */
     private int hash(Object... values) {
-        return Arrays.hashCode(values);
+        return hashCode(values);
+    }
+
+    public static int hashCode(Object a[]) {
+        if (a == null){
+            return 0;
+        }
+        int result = 1;
+        for (Object element : a){
+            result = 31 * result + (element == null ? 0 : element.hashCode());
+        }
+        return result;
     }
 }

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

@@ -56,13 +56,14 @@
 #### 1.2 该库功能说明
 |**类型** | 功能说明 |
 |--------   |-----        |
-|**项目结构** | VideoCache缓存lib,VideoKernel视频内核lib,VideoPlayer视频UI等lib |
+|**项目结构** | VideoCache缓存lib,VideoKernel视频内核lib,VideoPlayer视频UI等lib , VideoSqlLite视频位置二级缓存, VideoView视频悬浮lib , VideoM3u8下载m3u8以及合成库lib |
 |**内核** | MediaPlayer、ExoPlayer、IjkPlayer,后期接入Rtc和TXPlayer |
 |**协议/格式** | http/https、concat、rtsp、hls、rtmp、file、m3u8、mkv、webm、mp3、mp4等 |
 |**画面** | 调整显示比例:默认、16:9、4:3、填充;播放时旋转画面角度(0,90,180,270);镜像旋转 |
 |**布局** | 内核和UI分离,和市面GitHub上大多数播放器不一样,方便定制,通过addView添加 |
 |**播放** | 正常播放,小窗播放,列表播放,仿抖音播放 |
 |**自定义** | 可以自定义添加视频UI层,可以说UI和Player高度分离,支持自定义渲染层SurfaceView |
+|**视频播放位置本地记录** | 本地可以记录播放视频的播放位置,采用二级缓存模式:内存缓存 + 磁盘缓存 + key缓存 + 配置缓存大小和类型和路径|
 |**统一视频埋点** | 暴露用户播放视频开始,退出,异常,播放完成,以及退出视频时进度,点击广告,试看等多个统一埋点 |
 
 

+ 105 - 4
read/29.视频播放器埋点监听.md

@@ -86,10 +86,111 @@
 
 
 ### 04.如何配置使用
-
-
-
-
+- 只需要在初始化配置的时候,创建埋点监听类,代码如下所示,具体代码可以看BuriedPointEventImpl类。
+    ``` java
+    //播放器配置,注意:此为全局配置,按需开启
+    PlayerFactory player = PlayerFactoryUtils.getPlayer(PlayerConstant.PlayerType.TYPE_IJK);
+    VideoViewManager.setConfig(VideoPlayerConfig.newBuilder()
+            //设置上下文
+            .setContext(this)
+            //设置视频全局埋点事件
+            .setBuriedPointEvent(new BuriedPointEventImpl())
+            //调试的时候请打开日志,方便排错
+            .setLogEnabled(true)
+            //设置ijk
+            .setPlayerFactory(player)
+            .build());
+    ```
+- 关于BuriedPointEventImpl类代码说明,必须继承BuriedPointEvent约定的接口。这样操作就特别方面视频埋点操作,方便统一处理……
+    ```
+    public class BuriedPointEventImpl implements BuriedPointEvent {
+    
+        /**
+         * 进入视频播放
+         * @param url                       视频url
+         */
+        @Override
+        public void playerIn(String url) {
+            VideoLogUtils.i("BuriedPointEvent---进入视频播放--"+url);
+        }
+    
+        /**
+         * 退出视频播放
+         * @param url                       视频url
+         */
+        @Override
+        public void playerDestroy(String url) {
+            VideoLogUtils.i("BuriedPointEvent---退出视频播放--"+url);
+        }
+    
+        /**
+         * 视频播放完成
+         * @param url                       视频url
+         */
+        @Override
+        public void playerCompletion(String url) {
+            VideoLogUtils.i("BuriedPointEvent---视频播放完成--"+url);
+        }
+    
+        /**
+         * 视频播放异常
+         * @param url                       视频url
+         * @param isNetError                是否是网络异常
+         */
+        @Override
+        public void onError(String url, boolean isNetError) {
+            VideoLogUtils.i("BuriedPointEvent---视频播放异常--"+url);
+        }
+    
+        /**
+         * 点击了视频广告
+         * @param url                       视频url
+         */
+        @Override
+        public void clickAd(String url) {
+            VideoLogUtils.i("BuriedPointEvent---点击了视频广告--"+url);
+        }
+    
+        /**
+         * 视频试看点击
+         * @param url                       视频url
+         */
+        @Override
+        public void playerAndProved(String url) {
+            VideoLogUtils.i("BuriedPointEvent---视频试看点击--"+url);
+        }
+    
+        /**
+         * 退出视频播放时候的播放进度百度比
+         * @param url                       视频url
+         * @param progress                  视频进度,计算百分比【退出时候进度 / 总进度】
+         */
+        @Override
+        public void playerOutProgress(String url, float progress) {
+            VideoLogUtils.i("BuriedPointEvent---退出视频播放时候的播放进度百度比--"+url+"-----"+progress);
+        }
+    
+        /**
+         * 退出视频播放时候的播放进度
+         * @param url                       视频url
+         * @param duration                  总时长
+         * @param currentPosition           当前进度时长
+         */
+        @Override
+        public void playerOutProgress(String url, long duration, long currentPosition) {
+            VideoLogUtils.i("BuriedPointEvent---退出视频播放时候的播放进度百度比--"+url+"-----"+duration+"----"+currentPosition);
+        }
+    
+        /**
+         * 视频切换音频
+         * @param url                       视频url
+         */
+        @Override
+        public void videoToMedia(String url) {
+            VideoLogUtils.i("BuriedPointEvent---视频切换音频--"+url);
+        }
+    }
+    ```
 
 
 

+ 15 - 1
settings.gradle

@@ -1,8 +1,22 @@
+
+//视频弹幕
+include ':VideoBarrage'
+//视频录频
+include ':VideoRecorder'
+//视频投屏
 include ':VideoScreen'
+//视频播放位置记录二级缓存
 include ':VideoSqlLite'
+//m3u8下载和合成
 include ':VideoM3u8'
+//音频
 include ':MusicPlayer'
+//视频悬浮
 include ':VideoView'
+//视频内核
 include ':VideoKernel'
+//视频边播边缓存
 include ':VideoCache'
-include ':Demo', ':VideoPlayer'
+//视频播放器
+include ':VideoPlayer'
+include ':Demo'