SpringBoot+thymeleaf完成视频记忆播放功能

一、背景

1)客户要做一个视频播放功能,要求是系统能够记录观看人员在看视频时能够记录看到了哪个位置,在下次观看视频的时候能够从该位置进行播放。

2)同时,也要能够记录是谁看了视频,看了百分之多少。

说明:由于时间关系和篇幅原因,我们这里只先讨论第一个要求,第二个要求在后续不断完善的时候再更新。

二、思路

首先,我们先准备一个视频。然后建一个SpringBoot+thymeleaf的项目,将视频放入到项目中的Resource下,建议自己新建一个文件夹,如图所示:

然后,导入相关依赖——》配置相关属性文件——》在java后台写两个方法(一个方法是跳转到前端页面;另一个方法用来加载视频并返回。当跳转到前端时,通过html标签路径加载后台方法。)

接着,要写个前端页面用于展示,前端要配合JS使用。

最后,访问测试。

三、实现过程

1、添加依赖:

        <!-- 页面 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

注:pom全文参考如下(仅作为配置参考,不同环境有所不同):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>mybatisdemo02</artifactId>
    <version>0.0.1-SNAPSHOT</version>
   

最近更新

  1. TCP协议是安全的吗?

    2024-04-04 19:20:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-04 19:20:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-04 19:20:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-04 19:20:04       18 阅读

热门阅读

  1. 穿透 雪崩 击穿

    2024-04-04 19:20:04       20 阅读
  2. FastGpt流程

    2024-04-04 19:20:04       16 阅读
  3. 视觉和热成像技术在反无人机中应用

    2024-04-04 19:20:04       17 阅读
  4. RESTfull接口访问Elasticsearch

    2024-04-04 19:20:04       16 阅读
  5. python作用域

    2024-04-04 19:20:04       11 阅读
  6. Spring如何解决循环依赖

    2024-04-04 19:20:04       17 阅读
  7. spark单机版安装

    2024-04-04 19:20:04       13 阅读