File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 type AudioEventType ,
66} from "./BaseAudioPlayer" ;
77import type { EngineCapabilities } from "./IPlaybackEngine" ;
8+ import { useSettingStore } from "@/stores" ;
89
910/**
1011 * 基于 HTMLAudioElement 的播放器实现
@@ -196,11 +197,21 @@ export class AudioElementPlayer extends BaseAudioPlayer {
196197 if ( this . isInternalSeeking ) {
197198 return this . targetSeekTime ;
198199 }
200+ const settingStore = useSettingStore ( ) ;
201+
202+ const isPlayback = settingStore . audioLatencyHint === "playback" ;
203+
204+ let autoLatency = 0 ;
205+
206+ if ( isPlayback && this . audioCtx ) {
207+ autoLatency = ( this . audioCtx . outputLatency || 0 ) + ( this . audioCtx . baseLatency || 0 ) ;
208+ }
209+ const manualCompensation = isPlayback ? this . audioDelayCompensation / 1000 : 0 ;
199210 // 基础时间 - 自动延迟补偿 + 手动延迟补偿
200211 return (
201212 ( this . audioElement . currentTime || 0 ) -
202- this . compensatedLatency +
203- this . audioDelayCompensation / 1000
213+ autoLatency +
214+ manualCompensation
204215 ) ;
205216 }
206217
You can’t perform that action at this time.
0 commit comments