mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-20 18:31:30 +00:00
Fix Smart Speed playback time contract
This commit is contained in:
parent
5c747a7f8f
commit
97c5d6341e
9 changed files with 205 additions and 17 deletions
|
|
@ -399,14 +399,21 @@ export default class LocalAudioPlayer extends EventEmitter {
|
|||
getCurrentTime() {
|
||||
var currentTrackOffset = this.currentTrack.startOffset || 0
|
||||
if (!this.player) return 0
|
||||
|
||||
|
||||
if (this.enableSmartSpeed) {
|
||||
return this.timeMapper.audioToWallClock((currentTrackOffset + this.player.currentTime) * 1000) / 1000
|
||||
}
|
||||
return currentTrackOffset + this.player.currentTime
|
||||
}
|
||||
|
||||
getDuration() {
|
||||
if (!this.audioTracks.length) return 0
|
||||
var lastTrack = this.audioTracks[this.audioTracks.length - 1]
|
||||
return lastTrack.startOffset + lastTrack.duration
|
||||
const duration = lastTrack.startOffset + lastTrack.duration
|
||||
if (this.enableSmartSpeed) {
|
||||
return this.timeMapper.audioToWallClock(duration * 1000) / 1000
|
||||
}
|
||||
return duration
|
||||
}
|
||||
|
||||
setPlaybackRate(playbackRate) {
|
||||
|
|
@ -435,6 +442,10 @@ export default class LocalAudioPlayer extends EventEmitter {
|
|||
|
||||
var mappedTime = time
|
||||
|
||||
if (this.enableSmartSpeed) {
|
||||
mappedTime = this.timeMapper.wallClockToAudio(time * 1000) / 1000
|
||||
}
|
||||
|
||||
if (this.silenceDetectorNode) {
|
||||
this.silenceDetectorNode.port.postMessage({ type: 'reset' })
|
||||
this._silenceStartTime = null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue