feat: 连接歌词与实际播放进度
This commit is contained in:
parent
2fdec7688b
commit
1b2b8541da
|
@ -90,6 +90,7 @@ import { onMounted, ref, watch, nextTick, computed, onUnmounted } from 'vue'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import gsap from 'gsap'
|
import gsap from 'gsap'
|
||||||
import { usePlayQueueStore } from '../stores/usePlayQueueStore'
|
import { usePlayQueueStore } from '../stores/usePlayQueueStore'
|
||||||
|
import { usePlayState } from '../stores/usePlayState'
|
||||||
import { debugLyrics } from '../utils/debug'
|
import { debugLyrics } from '../utils/debug'
|
||||||
|
|
||||||
// 类型定义
|
// 类型定义
|
||||||
|
@ -108,6 +109,7 @@ interface GapLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
const playQueueStore = usePlayQueueStore()
|
const playQueueStore = usePlayQueueStore()
|
||||||
|
const playState = usePlayState()
|
||||||
|
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
const parsedLyrics = ref<(LyricsLine | GapLine)[]>([])
|
const parsedLyrics = ref<(LyricsLine | GapLine)[]>([])
|
||||||
|
@ -482,7 +484,7 @@ function getGapDotOpacities(line: GapLine) {
|
||||||
const duration = line.duration ?? 0
|
const duration = line.duration ?? 0
|
||||||
if (duration <= 0) return [0.3, 0.3, 0.3]
|
if (duration <= 0) return [0.3, 0.3, 0.3]
|
||||||
// 当前播放时间
|
// 当前播放时间
|
||||||
const now = playQueueStore.currentTime
|
const now = playState.playProgress
|
||||||
// gap 起止时间
|
// gap 起止时间
|
||||||
const start = line.time
|
const start = line.time
|
||||||
// 计算进度
|
// 计算进度
|
||||||
|
@ -498,7 +500,7 @@ function getGapDotOpacities(line: GapLine) {
|
||||||
|
|
||||||
// 监听播放时间变化
|
// 监听播放时间变化
|
||||||
watch(
|
watch(
|
||||||
() => playQueueStore.currentTime,
|
() => playState.playProgress,
|
||||||
(time) => {
|
(time) => {
|
||||||
const newIndex = findCurrentLineIndex(time)
|
const newIndex = findCurrentLineIndex(time)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user