新增HTTP开放API服务
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user