新增HTTP开放API服务

This commit is contained in:
lyswhut
2024-03-29 14:43:32 +08:00
parent 1e03791e82
commit 9c0ae12959
35 changed files with 681 additions and 340 deletions
@@ -227,4 +227,8 @@ export default class Lyric {
this._handleLinePlayerOnPlay(num, '', this.linePlayer._currentTime())
} else this.playingLineNum = 0
}
setAutoPause(autoPause) {
this.linePlayer.setAutoPause(autoPause)
}
}
@@ -224,4 +224,16 @@ export default class LinePlayer {
this.extendedLyrics = extendedLyrics
this._init()
}
setAutoPause(autoPause) {
if (autoPause) {
timeoutTools.nextTick = window.requestAnimationFrame.bind(window)
timeoutTools.cancelNextTick = window.cancelAnimationFrame.bind(window)
} else {
timeoutTools.nextTick = (handler) => {
return setTimeout(handler, 80)
}
timeoutTools.cancelNextTick = clearTimeout.bind(global)
}
}
}
+4 -2
View File
@@ -3,6 +3,8 @@ export const getNow = typeof performance == 'object' && window.performance.now ?
export class TimeoutTools {
constructor(thresholdTime = 80) {
this.nextTick = window.requestAnimationFrame.bind(window)
this.cancelNextTick = window.cancelAnimationFrame.bind(window)
this.invokeTime = 0
this.animationFrameId = null
this.timeoutId = null
@@ -11,7 +13,7 @@ export class TimeoutTools {
}
run() {
this.animationFrameId = window.requestAnimationFrame(() => {
this.animationFrameId = this.nextTick(() => {
this.animationFrameId = null
let diff = this.invokeTime - getNow()
// console.log('diff', diff)
@@ -39,7 +41,7 @@ export class TimeoutTools {
clear() {
if (this.animationFrameId) {
window.cancelAnimationFrame(this.animationFrameId)
this.cancelNextTick(this.animationFrameId)
this.animationFrameId = null
}
if (this.timeoutId) {