From 725c0aa29357202df47ca15a273a218fa40f28d8 Mon Sep 17 00:00:00 2001
From: number18 <3137007658@qq.com>
Date: Mon, 1 Jan 2024 13:23:23 +0800
Subject: [PATCH] =?UTF-8?q?=E6=A1=8C=E9=9D=A2=E6=A8=A1=E5=BC=8F=E4=B8=8B?=
=?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=EF=BC=8C=E4=BB=A5=E5=8F=8APlayerBar?=
=?UTF-8?q?=E9=9F=B3=E9=87=8F=E6=8C=87=E7=A4=BA=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/AudioPlayer.vue | 35 +++++++++++++++++++++++++++++++-
src/components/PlayerBar.vue | 37 ++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/src/components/AudioPlayer.vue b/src/components/AudioPlayer.vue
index 56c418f..9f92da2 100644
--- a/src/components/AudioPlayer.vue
+++ b/src/components/AudioPlayer.vue
@@ -244,6 +244,7 @@
+
{{ currentPlayingFile.title }}
@@ -407,9 +408,16 @@ export default {
this.histroyCheckIntervalId = setInterval(() => {
this.onUpdatePlayingStatus()
}, 60 * 1000) // 每隔一段时间更新一次播放记录
+
+ if (this.$q.platform.is.desktop) {
+ window.addEventListener('keydown', this.onKeyDown);
+ }
},
beforeDestroy() {
+ if (this.$q.platform.is.desktop) {
+ window.removeEventListener('keydown', this.onKeyDown);
+ }
clearInterval(this.histroyCheckIntervalId)
// 原本是想要在关闭窗口时,更新最后一次播放历史
@@ -855,7 +863,32 @@ export default {
if (!this.enableVisualizer) return; // 尚未开启音频可视化选项,无法使用音效均衡器
console.warn("flip cover");
this.isFlipCover = !this.isFlipCover;
- }
+ },
+
+ onKeyDown(event) {
+ // console.warn("key down code = ", event.code, ", activeElement is ", document.activeElement);
+ if (document.activeElement.tagName === "INPUT") return; // 禁止文本编辑的按键响应
+ if (this.playWorkId === 0) return; // 尚未播放任何作品时,禁止快捷键操作
+ const volumeStep = 0.04; // volume is between [0.0, 1.0]
+
+ switch(event.code) {
+ case "Space": this.togglePlaying(); break;
+ case "ArrowLeft": this.rewind(true); break;
+ case "ArrowRight": this.forward(true); break;
+
+ case "PageDown": this.nextTrack(); break;
+ case "PageUp": this.previousTrack(); break;
+
+ case "ArrowUp":
+ this.volume = Math.min(1.0, this.volume + volumeStep); break;
+ case "ArrowDown":
+ this.volume = Math.max(0.0, this.volume - volumeStep); break;
+ default: return; // return now
+ }
+
+ event.preventDefault()
+ event.stopPropagation()
+ },
},
created() {
diff --git a/src/components/PlayerBar.vue b/src/components/PlayerBar.vue
index e44489e..f30ef1b 100644
--- a/src/components/PlayerBar.vue
+++ b/src/components/PlayerBar.vue
@@ -14,7 +14,10 @@
color="primary"
:class="{}"
>
+
+
+
+
+
+
0) clearTimeout(this.volumeDelayHideTimeoutId);
+ this.showVolumeIndicator = true;
+ this.volumeDelayHideTimeoutId = setTimeout(() => {
+ this.showVolumeIndicator = false;
+ }, this.volumeDelayMills);
+ }
+ },
+
data() {
return {
OpState,
@@ -193,6 +213,11 @@ export default {
vertTriggerPixels: 15, // 向上触发像素距离
horizeTriggerPixels: 10, // 左右触发像素距离
+ showVolumeIndicator: false,
+ volumeIndicatorWidth: 8, // 音量指示器宽度 pixel
+ volumeDelayMills: 1000, // 音量指示器显示时间
+ volumeDelayHideTimeoutId: 0, // timeout id
+
startClientX: 0,
startClientY: 0,
startCurrentTime: 0,
@@ -355,6 +380,17 @@ export default {
height: 100%;
/* width: 100%; */
opacity: 1;
+ transition: 0.5s;
+}
+
+.volumeIndicator {
+ position: absolute;
+ background: rgba($warning, $alpha: 0.8);
+ height: 100%;
+ right: 0;
+ bottom: 0;
+ border-radius: 3px 3px 0 0;
+ transition: 0.5s;
}
.simple-progress-dark {
@@ -439,4 +475,5 @@ export default {
white-space: nowrap;
}
+