mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-16 08:21:29 +00:00
fix(client): fix smart speed seek race conditions and network buffering stall bugs
This commit is contained in:
parent
902d2448e1
commit
42a1a82e8a
2 changed files with 24 additions and 0 deletions
|
|
@ -57,6 +57,8 @@ export default class LocalAudioPlayer extends EventEmitter {
|
|||
this.player.addEventListener('error', this.evtError.bind(this))
|
||||
this.player.addEventListener('loadedmetadata', this.evtLoadedMetadata.bind(this))
|
||||
this.player.addEventListener('timeupdate', this.evtTimeupdate.bind(this))
|
||||
this.player.addEventListener('waiting', this.evtWaiting.bind(this))
|
||||
this.player.addEventListener('playing', this.evtPlaying.bind(this))
|
||||
|
||||
var mimeTypes = [
|
||||
'audio/flac',
|
||||
|
|
@ -213,6 +215,18 @@ export default class LocalAudioPlayer extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
evtWaiting() {
|
||||
if (this.audioContext && this.audioContext.state === 'running') {
|
||||
this.audioContext.suspend()
|
||||
}
|
||||
}
|
||||
|
||||
evtPlaying() {
|
||||
if (this.audioContext && this.audioContext.state === 'suspended') {
|
||||
this.audioContext.resume()
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.destroySilenceDetector()
|
||||
this.destroyHlsInstance()
|
||||
|
|
@ -421,6 +435,11 @@ export default class LocalAudioPlayer extends EventEmitter {
|
|||
|
||||
var mappedTime = time
|
||||
|
||||
if (this.silenceDetectorNode) {
|
||||
this.silenceDetectorNode.port.postMessage({ type: 'reset' })
|
||||
this._silenceStartTime = null
|
||||
}
|
||||
|
||||
this.silenceMap.reset()
|
||||
this.updateSmartSpeedRegions()
|
||||
this.playWhenReady = playWhenReady
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ class SilenceDetectorProcessor extends AudioWorkletProcessor {
|
|||
|
||||
this.port.onmessage = (event) => {
|
||||
const msg = event.data
|
||||
if (msg.type === 'reset') {
|
||||
this.state = SPEAKING
|
||||
this.candidateStartSample = 0
|
||||
return
|
||||
}
|
||||
if (msg.type === 'set-threshold') {
|
||||
this.silenceThreshold = msg.value
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue