当前位置:   article > 正文

java实现音频、视频离开页面存储收听记录、观看记录_springboot 完成视频记忆播放功能

springboot 完成视频记忆播放功能

    说明:本文是既《SpringBoot+thymeleaf完成视频记忆播放功能》的续写,如有兴趣可点击链接查看。

    一、功能背景描述说明:

    1、在手机浏览器离开时将看到的视频记录、视频时长和音频的收听记录、收听时长存入数据库记录;

    2、用户通过将观看、收听记录导出,能够看到是谁看了哪些视频、看了多长时间、上一次看到的位置等。

    二、实现过程:

    1)框架:SpringBoot+thymeleaf

    2)pom.xml文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.6.4</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.example</groupId>
  12. <artifactId>mybatisdemo02</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>mybatisdemo02</name>
  15. <description>Demo project for Spring Boot</description>
  16. <properties>
  17. <java.version>17</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-web</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-test</artifactId>
  27. <scope>test</scope>
  28. </dependency>
  29. <dependency>
  30. <groupId>org.mybatis</groupId>
  31. <artifactId>mybatis</artifactId>
  32. <version>3.5.2</version>
  33. </dependency>
  34. <dependency>
  35. <groupId>mysql</groupId>
  36. <artifactId>mysql-connector-java</artifactId>
  37. <version>8.0.15</version>
  38. </dependency>
  39. <!-- video player 读取视频播放时长-->
  40. <!--<dependency>
  41. <groupId>it.sauronsoftware</groupId>
  42. <artifactId>jave</artifactId>
  43. <version>1.0.2</version>
  44. </dependency>-->
  45. <!--视频多媒体工具包 包含 FFmpeg、OpenCV-->
  46. <dependency>
  47. <groupId>org.bytedeco</groupId>
  48. <artifactId>javacv-platform</artifactId>
  49. <version>1.5.3</version>
  50. </dependency>
  51. <!-- 音频依赖 -->
  52. <dependency>
  53. <groupId>ws.schild</groupId>
  54. <artifactId>jave-core</artifactId>
  55. <version>2.4.6</version>
  56. </dependency>
  57. <!--<dependency>
  58. <groupId>ws.schild</groupId>
  59. <artifactId>jave-nativebin-win32</artifactId>
  60. <version>3.1.1</version>
  61. </dependency>-->
  62. <dependency>
  63. <groupId>ws.schild</groupId>
  64. <artifactId>jave-native-win64</artifactId>
  65. <version>2.4.6</version>
  66. </dependency>
  67. <dependency>
  68. <groupId>org.webjars.bower</groupId>
  69. <artifactId>jquery</artifactId>
  70. <version>1.9.1</version>
  71. </dependency>
  72. <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
  73. <dependency>
  74. <groupId>commons-lang</groupId>
  75. <artifactId>commons-lang</artifactId>
  76. <version>2.6</version>
  77. </dependency>
  78. <dependency>
  79. <groupId>org.projectlombok</groupId>
  80. <artifactId>lombok</artifactId>
  81. </dependency>
  82. <dependency>
  83. <groupId>org.openjfx</groupId>
  84. <artifactId>javafx-controls</artifactId>
  85. <version>16</version>
  86. </dependency>
  87. <dependency>
  88. <groupId>com.alibaba</groupId>
  89. <artifactId>fastjson</artifactId>
  90. <version>2.0.21</version>
  91. </dependency>
  92. <!-- 页面 -->
  93. <dependency>
  94. <groupId>org.springframework.boot</groupId>
  95. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  96. </dependency>
  97. <!-- excle工具 -->
  98. <dependency>
  99. <groupId>org.apache.poi</groupId>
  100. <artifactId>poi-ooxml</artifactId>
  101. <version>4.1.2</version>
  102. </dependency>
  103. <!-- 时间日期工具 -->
  104. <dependency>
  105. <groupId>cn.hutool</groupId>
  106. <artifactId>hutool-core</artifactId>
  107. <version>5.8.14</version>
  108. </dependency>
  109. <dependency>
  110. <groupId>org.springframework.boot</groupId>
  111. <artifactId>spring-boot-starter-web</artifactId>
  112. <exclusions>
  113. <!-- 排除自带的logback依赖 -->
  114. <exclusion>
  115. <groupId>org.springframework.boot</groupId>
  116. <artifactId>spring-boot-starter-logging</artifactId>
  117. </exclusion>
  118. </exclusions>
  119. </dependency>
  120. <dependency>
  121. <groupId>org.springframework.boot</groupId>
  122. <artifactId>spring-boot-starter-log4j</artifactId>
  123. <version>1.3.8.RELEASE</version>
  124. </dependency>
  125. </dependencies>
  126. <build>
  127. <plugins>
  128. <plugin>
  129. <groupId>org.springframework.boot</groupId>
  130. <artifactId>spring-boot-maven-plugin</artifactId>
  131. </plugin>
  132. </plugins>
  133. <!-- 指向静态资源路径 -->
  134. <resources>
  135. <resource>
  136. <directory>src/main/java</directory>
  137. <includes>
  138. <include>**/*.properties</include>
  139. <include>**/*.xml</include>
  140. </includes>
  141. <filtering>true</filtering>
  142. </resource>
  143. </resources>
  144. </build>
  145. </project>

    3)配置application.properties属性文件

  1. server.port=8080
  2. spring.application.name=mybatisdemo02
  3. spring.thymeleaf.prefix=classpath:/templates/
  4. spring.web.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/templates/
  5. #pring.resources.static-locations=classpath:/static/
  6. spring.thymeleaf.suffix=.html
  7. spring.thymeleaf.mode=HTML5
  8. # mybatis日志打印
  9. mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
  10. log4j.logger.org.mybatis.caches=DEBUG

    4)配置log4j.properties属性文件

  1. log4j.logger.org.springframework.boot.autoconfigure=ERROR
  2. #log4j 配置
  3. #log4j定义了8个级别的log优先级从高到低依次为:OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、 ALL。
  4. #CONSOLE前面的DEBUG是控制台需要打印什么DEBUG级别以上的日志的信息
  5. log4j.rootLogger=DEBUG, CONSOLE, ERROR, WARN, INFO, DEBUG, ALL
  6. #-----------------------------------------------------------------------------------------------------
  7. #输出信息到控制台CONSOLE
  8. log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
  9. log4j.appender.CONSOLE.Target = System.out
  10. log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
  11. log4j.appender.CONSOLE.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
  12. #-----------------------------------------------------------------------------------------------------
  13. #输出ERROR 级别以上的日志到error.log
  14. log4j.logger.ERROR=ERROR
  15. log4j.appender.ERROR = org.apache.log4j.DailyRollingFileAppender
  16. log4j.appender.ERROR.File =E:/log/error.log
  17. log4j.appender.ERROR.Threshold = ERROR
  18. log4j.appender.ERROR.Append = true
  19. log4j.appender.ERROR.layout = org.apache.log4j.PatternLayout
  20. log4j.appender.ERROR.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
  21. #-----------------------------------------------------------------------------------------------------
  22. #输出DEBUG 级别以上的日志到debugger.log
  23. log4j.logger.org.apache.ibatis.cache.Cache=DEBUG
  24. log4j.appender.DEBUG = org.apache.log4j.DailyRollingFileAppender
  25. log4j.appender.DEBUG.File = E:/log/debugger.log
  26. log4j.appender.DEBUG.Threshold = DEBUG
  27. log4j.appender.DEBUG.Append = true
  28. log4j.appender.DEBUG.layout = org.apache.log4j.PatternLayout
  29. log4j.appender.DEBUG.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
  30. #-----------------------------------------------------------------------------------------------------
  31. #输出ALL级别的日志到all.log
  32. log4j.logger.ALL=ALL
  33. log4j.appender.ALL = org.apache.log4j.DailyRollingFileAppender
  34. log4j.appender.ALL.File = E:/log/all.log
  35. log4j.appender.file.DatePattern ='.'yyyy-MM-dd
  36. log4j.appender.ALL.Threshold = ALL
  37. log4j.appender.ALL.Append = true
  38. log4j.appender.ALL.layout = org.apache.log4j.PatternLayout
  39. log4j.appender.ALL.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

    5)配置mybatisConfig.xml

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE configuration
  3. PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-config.dtd">
  5. <configuration>
  6. <settings>
  7. <setting name="lazyLoadingEnabled" value="false" />
  8. <setting name="logImpl" value="STDOUT_LOGGING" />
  9. <!--二级缓存:全局地开启或关闭配置文件中的所有映射器已经配置的任何缓存。 -->
  10. <setting name="cacheEnabled" value="true"/>
  11. </settings>
  12. <typeAliases>
  13. <typeAlias type="com.example.mybatisdemo02.model.Person" alias="Person"/>
  14. <typeAlias type="com.example.mybatisdemo02.model.Warn" alias="Warn"/>
  15. </typeAliases>
  16. <!-- environments表示配置Mybatis的开发环境,可以配置多个环境,在众多具体环境中,使用default属性指定实际运行时使用的环境。default属性的取值是environment标签的id属性的值。 -->
  17. <environments default="development">
  18. <!-- environment表示配置Mybatis的一个具体的环境 -->
  19. <environment id="development">
  20. <!-- Mybatis的内置的事务管理器 -->
  21. <transactionManager type="JDBC"/>
  22. <!-- 配置数据源 -->
  23. <dataSource type="POOLED">
  24. <!-- 建立数据库连接的具体信息 -->
  25. <property name="driver" value="com.mysql.cj.jdbc.Driver" />
  26. <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useUnicode=true&amp;characterEncoding=utf8&amp;serverTimezone=GMT%2B8&amp;useSSL=false" />
  27. <property name="username" value="root"/>
  28. <property name="password" value="xxxxxx"/>
  29. </dataSource>
  30. </environment>
  31. </environments>
  32. <mappers>
  33. <!--引入映射文件-->
  34. <package name="com.example.mybatisdemo02.dao"></package>
  35. <!--<mapper resource="com/example/mybatisdemo/dao/PersonMapper.xml"
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/815340
推荐阅读
相关标签
  

闽ICP备14008679号