SpringBoot+thymeleaf實(shí)現(xiàn)讀取視頻列表并播放視頻功能_第1頁
SpringBoot+thymeleaf實(shí)現(xiàn)讀取視頻列表并播放視頻功能_第2頁
SpringBoot+thymeleaf實(shí)現(xiàn)讀取視頻列表并播放視頻功能_第3頁
SpringBoot+thymeleaf實(shí)現(xiàn)讀取視頻列表并播放視頻功能_第4頁
SpringBoot+thymeleaf實(shí)現(xiàn)讀取視頻列表并播放視頻功能_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

第SpringBoot+thymeleaf實(shí)現(xiàn)讀取視頻列表并播放視頻功能目錄效果實(shí)現(xiàn)過程后端程序示例前端程序示例通過讀取數(shù)據(jù)庫video表獲取當(dāng)前視頻的視頻名、視頻地址,展示至前端頁面videorecord.html,通過點(diǎn)擊播放按鈕獲取數(shù)據(jù)id進(jìn)而得到所選視頻地址,跳轉(zhuǎn)播放視頻顯示頁videoshow.html,播放所選視頻。當(dāng)然本案例只是為了展示主要的一些功能,其他比如跳轉(zhuǎn)、頁面布局美化等可以自行進(jìn)行更改。

效果

Springboot播放視頻

實(shí)現(xiàn)過程

后端程序示例

1.Controller層示例

返回?cái)?shù)據(jù)庫數(shù)據(jù)時(shí),使用了pagehelp當(dāng)中的PageInfo,為了后期擴(kuò)展分頁功能,正常寫法返回值類型應(yīng)為實(shí)體類Video.

packagecom.dvms.controller;

*文件名:VideoController

*創(chuàng)建者:CJW

*創(chuàng)建時(shí)間:2025/4/1416:40

*描述:TODO

importcom.dvms.entity.Video;

importcom.dvms.service.ParamoduleService;

importcom.github.pagehelper.PageInfo;

importorg.springframework.beans.factory.annotation.Autowired;

importorg.springframework.stereotype.Controller;

importorg.springframework.ui.Model;

importorg.springframework.web.bind.annotation.RequestMapping;

@Controller

publicclassVideoController{

@Autowired

privateParamoduleServiceparamoduleService;

//查出記錄

@RequestMapping("/angle/findvideoRecord")

publicStringfindvideorecords(Modelmodel){

System.out.println(paramoduleService.findvideorecord());

PageInfoVideovideoRecord=newPageInfo(paramoduleService.findvideorecord());

model.addAttribute("videorecord",videoRecord);

return"angle/videorecord";

//查出視頻地址

@RequestMapping("/angle/findvideo")

publicStringfindvideo(Stringid,Stringfilenamev,Modelmodel){

System.out.println(id);

Stringvideopath=paramoduleService.findvideo(id);

System.out.println(videopath);

model.addAttribute("videourl",videopath);

model.addAttribute("videoname",filenamev);

return"angle/videoshow";

2.Service層

packagecom.dvms.service;

importcom.dvms.entity.Record;

importcom.dvms.entity.Video;

importjava.util.List;

importjava.util.Map;

*文件名:ParamoduleService

*創(chuàng)建者:CJW

*創(chuàng)建時(shí)間:2025/1/1510:54

*描述:TODO

publicinterfaceParamoduleService{

Stringfindvideo(Stringid);

ListVideofindvideorecord();

3.ServiceImpl層

packagecom.dvms.service.Impl;

importcom.dvms.dao.ParamoduleDao;

importcom.dvms.entity.Record;

importcom.dvms.entity.Video;

importcom.dvms.service.ParamoduleService;

importorg.springframework.beans.factory.annotation.Autowired;

importorg.springframework.stereotype.Service;

importjava.util.List;

importjava.util.Map;

*文件名:ParamoduleServiceImpl

*創(chuàng)建者:CJW

*創(chuàng)建時(shí)間:2025/1/1510:55

*描述:TODO

@Service

publicclassParamoduleServiceImplimplementsParamoduleService{

@Autowired

privateParamoduleDaoparamoduleDao;

//查出視頻文件地址

@Override

publicStringfindvideo(Stringid){

returnparamoduleDao.findvideo(id);

//查出視頻記錄

@Override

publicListVideofindvideorecord(){

returnparamoduleDao.findvideorecord();

4.dao(mapper)層

packagecom.dvms.dao;

importcom.dvms.entity.Record;

importcom.dvms.entity.Video;

importorg.springframework.stereotype.Repository;

importjava.util.List;

importjava.util.Map;

*文件名:ParamoduleDao

*創(chuàng)建者:CJW

*創(chuàng)建時(shí)間:2025/1/1510:52

*描述:TODO

@Repository

publicinterfaceParamoduleDao{

Stringfindvideo(Stringid);

ListVideofindvideorecord();

4.entity(pojo)層

packagecom.dvms.entity;

*文件名:Video

*創(chuàng)建者:CJW

*創(chuàng)建時(shí)間:2025/4/1416:17

*描述:TODO

importlombok.AllArgsConstructor;

importlombok.Data;

importlombok.NoArgsConstructor;

importlombok.ToString;

importlombok.experimental.Accessors;

@Data

@ToString

@AllArgsConstructor

@NoArgsConstructor

@Accessors(chain=true)//鏈?zhǔn)秸{(diào)用

publicclassVideo{

privateStringid;

privateStringfilename;

privateStringfilepath;

5.daoMapper.xml

xmlversion="1.0"encoding="UTF-8"

!DOCTYPEmapper

PUBLIC"-////DTDMapper3.0//EN"

"/dtd/mybatis-3-mapper.dtd"

mappernamespace="com.dvms.dao.ParamoduleDao"

!--查詢存在視頻--

selectid="findvideo"resultType="String"

selectfilepathfromvideowhereid=#{id}

/select

!--查詢存在視頻記錄--

selectid="findvideorecord"resultType="Video"

selectid,filename,filepathfromvideo

/select

/mapper

6.video數(shù)據(jù)庫表結(jié)構(gòu)

前端程序示例

前端需引入thymeleaf、bootstrap等

1.videorecord.html

div

!--MAINCONTENT--

div

div

h3視頻管理/h3

div

div

!--BASICTABLE--

div

div

divh3視頻記錄/h3/div

!--hr--

/div

div

table

tdhidden

/td

視頻文件名

/td

/td

/tr

trth:class="${rowstate.odd}'row1':'row2'"th:each="video,rowstate:${videorecord.list}"

tdhidden

spanth:text="${video.id}"/span

/td

spanth:text="${video.filename}"/span

/td

atype="button"th:href="@{/angle/findvideo(id=${video.id},filenamev=${video.filename})}"rel="externalnofollow"播放/anbsp;

atype="button"th:href="@{/angle/findvideo(id=${video.id})}"rel="externalnofollow"下載/anbsp;

/td

/tr

/table

div

/div

/div

/div

!--ENDCONDENSEDTABLE--

/div

/div

/div

/div

!--ENDMAINCONTENT--

/div

2.videoshow.html

div

!--MAINCONTENT--

div

div

h3播放視頻示例/h3

div

div

div

aspan當(dāng)前播放視頻:/spanspanth:text="${videoname}"/span/a

/div

/div

/div

div

!--BASICTABLE--

div

div

div

table

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

/td

!--imgth:src="${imageurl}"--

videoalign="center"width="800"height="550"controls

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論