Demo介绍
批处理脚本生成视频列表
@echo off
setlocal enabledelayedexpansion
set folderPath="E:\Videos"
set outputPath="%cd%\视频列表.txt"
set fileExtension=MP4
echo var videos = [ > %outputPath%
for %%f in (%folderPath%\*.%fileExtension%) do (
set "fileName=%%~nxf"
set "fileTitle=%%~nf"
echo { >> %outputPath%
echo src: "!fileName!", >> %outputPath%
echo title: "!fileTitle!" >> %outputPath%
echo }, >> %outputPath%
)
echo ]; >> %outputPath%
完整代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
margin: 0;
}
.one {
width: 100%;
height: 100vh;
display: flex;
overflow: hidden;
}
.one #videoList {
width: 300px;
height: 100%;
max-height: 100vh;
margin: 0px;
color: #fff;
background: rgb(123, 202, 252);
overflow: scroll;
overflow-x: hidden;
padding-left: 0;
border: 8px groove rgb(123, 202, 252);
}
.one #videoList::-webkit-scrollbar {
width: 0;
height: 0;
}
.one #videoList li {
cursor: pointer;
line-height: 30px;
border-bottom: 1px solid #fff;
padding: 10px;
list-style: none;
margin: 0px;
}
.one #videoList li:hover {
font-weight: bold;
}
.one .selected {
background: #fff;
color: rgb(123, 202, 252);
font-weight: bold;
}
.one #myVideo {
border: 8px groove rgb(123, 202, 252);
}
</style>
</head>
<body>
<div class="one">
<ul id="videoList"></ul>
<video id="myVideo" width="600" height="400" controls></video>
</div>
<script>
var videoList = document.getElementById('videoList');
var myVideo = document.getElementById('myVideo');
var videos = [];
videos.forEach(function (video, index) {
var li = document.createElement('li');
li.textContent = video.title;
li.setAttribute('data-src', video.src);
li.addEventListener('click', function () {
loadVideo(video.src, li);
});
videoList.appendChild(li);
});
function loadVideo(src, listItem) {
myVideo.src = src;
myVideo.play();
var selected = document.querySelector('.selected');
if (selected) {
selected.classList.remove('selected');
}
listItem.classList.add('selected');
}
if (videos.length > 0) {
loadVideo(videos[0].src, videoList.children[0]);
}
</script>
</body>
</html>
