Fix Smart Speed playback time contract

This commit is contained in:
Jonathan Baldie 2026-05-02 00:25:37 +01:00
parent 5c747a7f8f
commit 97c5d6341e
9 changed files with 205 additions and 17 deletions

View file

@ -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