Skip to content

一分钟搭建影视站,支持Docker等部署方式

Add keyboard shortcut hints and styles to player.html and update README

developerfa4bed9d8460
diff --git a/player.html b/player.html
index e9ddfcf..ef2e326 100644
--- a/player.html
+++ b/player.html
@@ -118,6 +118,27 @@
input:checked + .slider:before {
transform: translateX(22px);
}
+ /* 添加快捷键提示样式 */
+ .shortcut-hint {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ background-color: rgba(0, 0, 0, 0.8);
+ color: white;
+ padding: 1rem 2rem;
+ border-radius: 0.5rem;
+ font-size: 1.5rem;
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ z-index: 1000;
+ opacity: 0;
+ transition: opacity 0.3s ease;
+ }
+ .shortcut-hint.show {
+ opacity: 1;
+ }
</style>
</head>
<body>
@@ -200,6 +221,14 @@
</div>
</main>
+ <!-- 添加快捷键提示元素 -->
+ <div class="shortcut-hint" id="shortcutHint">
+ <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" id="shortcutIcon">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
+ </svg>
+ <span id="shortcutText"></span>
+ </div>
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/hls.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/DPlayer.min.js"></script>
<script src="js/config.js"></script>
@@ -215,6 +244,7 @@
let isUserSeeking = false; // 跟踪用户是否正在拖动进度条
let videoHasEnded = false; // 跟踪视频是否已经自然结束
let userClickedPosition = null; // 记录用户点击的位置
+ let shortcutHintTimeout = null; // 用于控制快捷键提示显示时间
// 页面加载
document.addEventListener('DOMContentLoaded', function() {
@@ -274,8 +304,64 @@
setTimeout(() => {
setupProgressBarPreciseClicks();
}, 1000);
+
+ // 添加键盘快捷键事件监听
+ document.addEventListener('keydown', handleKeyboardShortcuts);
});
+ // 新增:处理键盘快捷键
+ function handleKeyboardShortcuts(e) {
+ // 忽略输入框中的按键事件
+ if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
+
+ // Alt + 左箭头 = 上一集
+ if (e.altKey && e.key === 'ArrowLeft') {
+ if (currentEpisodeIndex > 0) {
+ playPreviousEpisode();
+ showShortcutHint('上一集', 'left');
+ e.preventDefault();
+ }
+ }
+
+ // Alt + 右箭头 = 下一集
+ if (e.altKey && e.key === 'ArrowRight') {
+ if (currentEpisodeIndex < currentEpisodes.length - 1) {
+ playNextEpisode();
+ showShortcutHint('下一集', 'right');
+ e.preventDefault();
+ }
+ }
+ }
+
+ // 新增:显示快捷键提示
+ function showShortcutHint(text, direction) {
+ const hintElement = document.getElementById('shortcutHint');
+ const textElement = document.getElementById('shortcutText');
+ const iconElement = document.getElementById('shortcutIcon');
+
+ // 清除之前的超时
+ if (shortcutHintTimeout) {
+ clearTimeout(shortcutHintTimeout);
+ }
+
+ // 设置文本和图标方向
+ textElement.textContent = text;
+
+ if (direction === 'left') {
+ iconElement.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>';
+ } else {
+ iconElement.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>';
+ }
+
+ // 显示提示
+ hintElement.classList.add('show');
+
+ // 两秒后隐藏
+ shortcutHintTimeout = setTimeout(() => {
+ hintElement.classList.remove('show');
+ }, 2000);
+ }
+
// 初始化播放器
function initPlayer(videoUrl) {
if (!videoUrl) return;
diff --git a/readme.md b/readme.md
index 2f908da..a04ab4b 100644
--- a/readme.md
+++ b/readme.md
@@ -22,6 +22,18 @@ LibreTV是一个轻量级、免费的在线视频搜索与观看平台,提供
- 🚀 纯静态部署,无需后端服务器
- 🛡️ 内置广告过滤功能,提供更干净的观影体验
- 🎬 自定义视频播放器,支持HLS流媒体格式
+- ⌨️ 键盘快捷键支持,提高观影体验
+
+## ⌨️ 键盘快捷键
+
+LibreTV播放器支持以下键盘快捷键:
+
+- **Alt + 左箭头**:播放上一集
+- **Alt + 右箭头**:播放下一集
+- **空格键**:暂停/播放
+- **左/右箭头**:快退/快进5秒
+- **上/下箭头**:调整音量
+- **F**:全屏/退出全屏
## 📹 视频源支持说明