优化进度条逻辑
parent
cffa74b1c2
commit
63141c4ac9
|
@ -13,8 +13,8 @@ div(:class="$style.player")
|
||||||
|
|
||||||
div(:class="$style.volumeContent")
|
div(:class="$style.volumeContent")
|
||||||
div(:class="[$style.volume, setting.player.isMute ? $style.muted : null]")
|
div(:class="[$style.volume, setting.player.isMute ? $style.muted : null]")
|
||||||
div(:class="$style.volumeBar" :style="{ transform: `scaleX(${volume || 0})` }")
|
div(:class="$style.volumeBar" ref="com_volumeBar" :style="{ transform: `scaleX(${volume || 0})` }")
|
||||||
div(:class="$style.volumeMask" @mousedown="handleVolumeMsDown" ref="dom_volumeMask" :tips="`${$t('core.player.volume')}${parseInt(volume * 100)}%`")
|
div(:class="$style.volumeMask" @mousedown="handleVolumeMsDown" :tips="`${$t('core.player.volume')}${parseInt(volume * 100)}%`")
|
||||||
div(:class="$style.titleBtn" @click='toggleDesktopLyric' @contextmenu="handleToggleLockDesktopLyric" :tips="toggleDesktopLyricBtnTitle")
|
div(:class="$style.titleBtn" @click='toggleDesktopLyric' @contextmenu="handleToggleLockDesktopLyric" :tips="toggleDesktopLyricBtnTitle")
|
||||||
svg(v-if="setting.desktopLyric.enable" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 512 512' space='preserve')
|
svg(v-if="setting.desktopLyric.enable" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 512 512' space='preserve')
|
||||||
use(xlink:href='#icon-desktop-lyric-on')
|
use(xlink:href='#icon-desktop-lyric-on')
|
||||||
|
@ -122,7 +122,6 @@ export default {
|
||||||
album: '',
|
album: '',
|
||||||
},
|
},
|
||||||
currentMusicInfo: {},
|
currentMusicInfo: {},
|
||||||
pregessWidth: 0,
|
|
||||||
lyric: {
|
lyric: {
|
||||||
lines: [],
|
lines: [],
|
||||||
text: '',
|
text: '',
|
||||||
|
@ -197,9 +196,6 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init()
|
this.init()
|
||||||
this.$nextTick(() => {
|
|
||||||
this.setProgressWidth()
|
|
||||||
})
|
|
||||||
this.handleSaveVolume = debounce(volume => {
|
this.handleSaveVolume = debounce(volume => {
|
||||||
this.setVolume(volume)
|
this.setVolume(volume)
|
||||||
}, 300)
|
}, 300)
|
||||||
|
@ -242,13 +238,11 @@ export default {
|
||||||
navigator.mediaDevices.addEventListener('devicechange', this.handleMediaListChange)
|
navigator.mediaDevices.addEventListener('devicechange', this.handleMediaListChange)
|
||||||
document.addEventListener('mousemove', this.handleVolumeMsMove)
|
document.addEventListener('mousemove', this.handleVolumeMsMove)
|
||||||
document.addEventListener('mouseup', this.handleVolumeMsUp)
|
document.addEventListener('mouseup', this.handleVolumeMsUp)
|
||||||
window.addEventListener('resize', this.handleResize)
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
navigator.mediaDevices.removeEventListener('devicechange', this.handleMediaListChange)
|
navigator.mediaDevices.removeEventListener('devicechange', this.handleMediaListChange)
|
||||||
document.removeEventListener('mousemove', this.handleVolumeMsMove)
|
document.removeEventListener('mousemove', this.handleVolumeMsMove)
|
||||||
document.removeEventListener('mouseup', this.handleVolumeMsUp)
|
document.removeEventListener('mouseup', this.handleVolumeMsUp)
|
||||||
window.removeEventListener('resize', this.handleResize)
|
|
||||||
this.handleRegisterEvent('off')
|
this.handleRegisterEvent('off')
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -445,6 +439,7 @@ export default {
|
||||||
// })
|
// })
|
||||||
audio.addEventListener('emptied', () => {
|
audio.addEventListener('emptied', () => {
|
||||||
this.mediaBuffer.playTime = 0
|
this.mediaBuffer.playTime = 0
|
||||||
|
this.clearDelayNextTimeout()
|
||||||
this.clearLoadingTimeout()
|
this.clearLoadingTimeout()
|
||||||
this.clearBufferTimeout()
|
this.clearBufferTimeout()
|
||||||
|
|
||||||
|
@ -550,10 +545,6 @@ export default {
|
||||||
this.playNext()
|
this.playNext()
|
||||||
}, 5000)
|
}, 5000)
|
||||||
},
|
},
|
||||||
|
|
||||||
hanldeListRandom(list, index) {
|
|
||||||
return getRandom(0, list.length)
|
|
||||||
},
|
|
||||||
startPlay() {
|
startPlay() {
|
||||||
this.isPlay = true
|
this.isPlay = true
|
||||||
if (this.musicInfo.lrc) window.lrc.play(audio.currentTime * 1000)
|
if (this.musicInfo.lrc) window.lrc.play(audio.currentTime * 1000)
|
||||||
|
@ -578,7 +569,7 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleSetProgress(event) {
|
handleSetProgress(event) {
|
||||||
this.setProgress(event.offsetX / this.pregessWidth * this.maxPlayTime)
|
this.setProgress(event.offsetX / this.$refs.dom_progress.clientWidth * this.maxPlayTime)
|
||||||
},
|
},
|
||||||
setProgress(time) {
|
setProgress(time) {
|
||||||
if (!audio.src) return
|
if (!audio.src) return
|
||||||
|
@ -592,11 +583,7 @@ export default {
|
||||||
|
|
||||||
if (!this.isPlay) audio.play()
|
if (!this.isPlay) audio.play()
|
||||||
},
|
},
|
||||||
setProgressWidth() {
|
|
||||||
this.pregessWidth = parseInt(
|
|
||||||
window.getComputedStyle(this.$refs.dom_progress, null).width,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
async togglePlay() {
|
async togglePlay() {
|
||||||
if (!audio.src) {
|
if (!audio.src) {
|
||||||
if (this.restorePlayTime != null) {
|
if (this.restorePlayTime != null) {
|
||||||
|
@ -761,7 +748,7 @@ export default {
|
||||||
},
|
},
|
||||||
handleVolumeMsMove(e) {
|
handleVolumeMsMove(e) {
|
||||||
if (!this.volumeEvent.isMsDown) return
|
if (!this.volumeEvent.isMsDown) return
|
||||||
this.handleSetVolume(this.volumeEvent.msDownVolume + (e.clientX - this.volumeEvent.msDownX) / 80)
|
this.handleSetVolume(this.volumeEvent.msDownVolume + (e.clientX - this.volumeEvent.msDownX) / this.$refs.com_volumeBar.clientWidth)
|
||||||
},
|
},
|
||||||
handleSetVolumeUp(step = 0.02) {
|
handleSetVolumeUp(step = 0.02) {
|
||||||
this.handleSetVolume(this.volume + step)
|
this.handleSetVolume(this.volume + step)
|
||||||
|
@ -776,9 +763,6 @@ export default {
|
||||||
handleCopy(text) {
|
handleCopy(text) {
|
||||||
clipboardWriteText(text)
|
clipboardWriteText(text)
|
||||||
},
|
},
|
||||||
handleResize() {
|
|
||||||
this.setProgressWidth()
|
|
||||||
},
|
|
||||||
handleToMusicLocation() {
|
handleToMusicLocation() {
|
||||||
if (!this.listId || this.listId == '__temp__' || this.listId == 'download' || !this.currentMusicInfo.songmid) return
|
if (!this.listId || this.listId == '__temp__' || this.listId == 'download' || !this.currentMusicInfo.songmid) return
|
||||||
if (this.playIndex == -1) return
|
if (this.playIndex == -1) return
|
||||||
|
|
|
@ -208,6 +208,7 @@ module.exports = class FontPlayer {
|
||||||
if (this.delay > 0) {
|
if (this.delay > 0) {
|
||||||
this._handlePlayFont(curFont, driftTime)
|
this._handlePlayFont(curFont, driftTime)
|
||||||
this.timeoutTools.start(() => {
|
this.timeoutTools.start(() => {
|
||||||
|
if (!this.isPlay) return
|
||||||
this._refresh()
|
this._refresh()
|
||||||
}, this.delay)
|
}, this.delay)
|
||||||
return
|
return
|
||||||
|
@ -215,6 +216,7 @@ module.exports = class FontPlayer {
|
||||||
} else if (this.curFontNum == 0) {
|
} else if (this.curFontNum == 0) {
|
||||||
this.curFontNum--
|
this.curFontNum--
|
||||||
this.waitPlayTimeout.start(() => {
|
this.waitPlayTimeout.start(() => {
|
||||||
|
if (!this.isPlay) return
|
||||||
this._refresh()
|
this._refresh()
|
||||||
}, -driftTime)
|
}, -driftTime)
|
||||||
return
|
return
|
||||||
|
|
|
@ -125,6 +125,7 @@ module.exports = class LinePlayer {
|
||||||
this.isOffseted = true
|
this.isOffseted = true
|
||||||
}
|
}
|
||||||
timeoutTools.start(() => {
|
timeoutTools.start(() => {
|
||||||
|
if (!this.isPlay) return
|
||||||
this._refresh()
|
this._refresh()
|
||||||
}, this.delay)
|
}, this.delay)
|
||||||
this.onPlay(this.curLineNum, curLine.text, currentTime)
|
this.onPlay(this.curLineNum, curLine.text, currentTime)
|
||||||
|
|
Loading…
Reference in New Issue