forked from hexianglong/o.nmgjg.com.cn
- 移除了使用 fetch API 下载视频的复杂逻辑 - 采用直接创建 <a> 元素并触发点击的方法简化下载过程 - 修改了下载文件名的生成逻辑,使用 URL 的最后一部分作为文件名
111 lines
3.5 KiB
HTML
111 lines
3.5 KiB
HTML
<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 = "./Big Buck Bunny_1080P_60fps.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() {
|
|
var link = document.createElement('a');
|
|
link.href = videoUrl;
|
|
link.download = videoUrl.split('/').pop();
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
document.body.removeChild(link);
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html> |