refactor: 删除旧的视频页面

- 移除了 index/videos/index.html 文件
- 该页面包含过时的内容和样式,不利于用户体验
This commit is contained in:
2025-02-06 13:55:16 +08:00
Unverified
parent 9228893644
commit 98178b8812
4 changed files with 250 additions and 36 deletions

8
index/artplayer.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,125 @@
<html lang="zh-CN">
<head>
<title id="pageTitle">视频播放</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.artplayer-app {
width: 100%;
height: calc(100vh - 50px);
/* 调整高度以适应标题栏 */
margin: 0;
border: 1px solid #ccc;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
display: flex;
flex-direction: column;
height: 100vh;
/* 设置body高度为视口高度 */
overflow: hidden;
/* 隐藏滚动条 */
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
background-color: #fff;
border-bottom: 1px solid #ccc;
}
h1 {
color: #333;
margin: 0;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="header">
<h1 id="videoTitle">视频播放</h1>
<button onclick="downloadVideo()">下载</button>
</div>
<div class="artplayer-app"></div>
<script src="https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js"></script>
<!-- 引入 artplayerPluginChapter 插件 -->
<script src="https://cdn.jsdelivr.net/npm/artplayer-plugin-chapter/dist/artplayer-plugin-chapter.js"></script>
<script>
// 定义视频标题和链接
var videoTitle = "视频标题";
var videoUrl = "./video.mp4";
// 设置视频标题
document.getElementById('videoTitle').innerText = videoTitle;
// 设置页面标题
document.getElementById('pageTitle').innerText = videoTitle + " - 播放";
var art = new Artplayer({
container: '.artplayer-app',
url: videoUrl,
autoSize: true,
fullscreen: true,
fullscreenWeb: true,
miniProgressBar: true,
autoOrientation: true,
autoplay: false, // 禁用自动播放
muted: false, // 不自动静音
setting: true,
aspectRatio: true,
fullscreen: true,
lang: 'zh-cn',
fastForward: true,
plugins: [
artplayerPluginChapter({
chapters: [
{ start: 0, end: 18, title: '1' },
{ start: 18, end: 36, title: '2' },
{ start: 36, end: 54, title: '3' },
{ start: 54, end: 72, title: '4' },
{ start: 72, end: Infinity, title: '5' },
]
}),
],
});
function downloadVideo() {
fetch(videoUrl)
.then(response => response.blob())
.then(blob => {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = videoTitle + '.mp4'; // 设置下载文件名
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(link.href);
})
.catch(error => console.error('Error downloading the video:', error));
}
</script>
</body>
</html>

View File

@@ -1,36 +0,0 @@
<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<html>
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex,nofollow" />
<title>提醒</title>
<style>
.container {
width: 60%;
margin: 10% auto 0;
background-color: #f0f0f0;
padding: 2% 5%;
border-radius: 10px
}
ul {
padding-left: 20px;
}
ul li {
line-height: 2.3
}
a {
color: #20a53a
}
</style>
</head>
<body>
<div class="container">
<h1>网站建设中!</h1>
<h3>https://artplayer.org/?libs=.%2Funcompiled%2Fartplayer-plugin-chapter%2Findex.js&code=%2F%2F%20npm%20i%20artplayer-plugin-chapter%0A%2F%2F%20import%20artplayerPluginChapter%20from%20%27artplayer-plugin-chapter%27%3B%0A%0Avar%20art%20%3D%20new%20Artplayer(%7B%0A%20%20%20%20container%3A%20%27.artplayer-app%27%2C%0A%20%20%20%20url%3A%20%27%2Fassets%2Fsample%2Fvideo.mp4%27%2C%0A%20%20%20%20autoSize%3A%20true%2C%0A%09fullscreen%3A%20true%2C%0A%09fullscreenWeb%3A%20true%2C%0A%09miniProgressBar%3A%20true%2C%0A%09autoOrientation%3A%20true%2C%0A%20%20%20%20plugins%3A%20%5B%0A%20%20%20%20%20%20%20%20artplayerPluginChapter(%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20chapters%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20start%3A%200%2C%20end%3A%2018%2C%20title%3A%20%27One%20more%20chance%27%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20start%3A%2018%2C%20end%3A%2036%2C%20title%3A%20%27%E8%B0%81%E3%81%A7%E3%82%82%E3%81%84%E3%81%84%E3%81%AF%E3%81%9A%E3%81%AA%E3%81%AE%E3%81%AB%27%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20start%3A%2036%2C%20end%3A%2054%2C%20title%3A%20%27%E5%A4%8F%E3%81%AE%E6%83%B3%E3%81%84%E5%87%BA%E3%81%8C%E3%81%BE%E3%82%8F%E3%82%8B%27%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20start%3A%2054%2C%20end%3A%2072%2C%20title%3A%20%27%E3%81%93%E3%82%93%E3%81%AA%E3%81%A8%E3%81%93%E3%81%AB%E3%81%82%E3%82%8B%E3%81%AF%E3%81%9A%E3%82%82%E3%81%AA%E3%81%84%E3%81%AE%E3%81%AB%27%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20start%3A%2072%2C%20end%3A%20Infinity%2C%20title%3A%20%27%E7%BB%88%E3%82%8F%E3%82%8A%27%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%5D%2C%0A%7D)%3B</h3>
</div>
</body>
</html>

View File

@@ -0,0 +1,117 @@
<html lang="zh-CN">
<head>
<title id="pageTitle">视频播放</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.artplayer-app {
width: 100%;
height: calc(100vh - 50px); /* 调整高度以适应标题栏 */
margin: 0;
border: 1px solid #ccc;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
display: flex;
flex-direction: column;
height: 100vh; /* 设置body高度为视口高度 */
overflow: hidden; /* 隐藏滚动条 */
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
background-color: #fff;
border-bottom: 1px solid #ccc;
}
h1 {
color: #333;
margin: 0;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="header">
<h1 id="videoTitle">视频播放</h1>
<button onclick="downloadVideo()">下载</button>
</div>
<div class="artplayer-app"></div>
<script src="https://cdn.jsdelivr.net/npm/artplayer/dist/artplayer.js"></script>
<!-- 引入 artplayerPluginChapter 插件 -->
<script src="https://cdn.jsdelivr.net/npm/artplayer-plugin-chapter/dist/artplayer-plugin-chapter.js"></script>
<script>
// 定义视频标题和链接
var videoTitle = "视频标题";
var videoUrl = "./video.mp4";
// 设置视频标题
document.getElementById('videoTitle').innerText = videoTitle;
// 设置页面标题
document.getElementById('pageTitle').innerText = videoTitle + " - 播放";
var art = new Artplayer({
container: '.artplayer-app',
url: videoUrl,
autoSize: true,
fullscreen: true,
fullscreenWeb: true,
miniProgressBar: true,
autoOrientation: true,
autoplay: false, // 禁用自动播放
muted: false, // 不自动静音
setting: true,
aspectRatio: true,
fullscreen: true,
lang: 'zh-cn',
fastForward: true,
plugins: [
artplayerPluginChapter({
chapters: [
{ start: 0, end: 18, title: '1' },
{ start: 18, end: 36, title: '2' },
{ start: 36, end: 54, title: '3' },
{ start: 54, end: 72, title: '4' },
{ start: 72, end: Infinity, title: '5' },
]
}),
],
});
function downloadVideo() {
fetch(videoUrl)
.then(response => response.blob())
.then(blob => {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = videoTitle + '.mp4'; // 设置下载文件名
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(link.href);
})
.catch(error => console.error('Error downloading the video:', error));
}
</script>
</body>
</html>