fix(danmuku): [PKG-DANMUKU-START-01] retain the initial playback sampling interval

This commit is contained in:
Harvey Zhao committed 2026-09-16 00:14:48 +08:00
1 parent b5f8b5e28e
commit 267b21226a
19 files changed
+9004 -26

No files matched your search

@@ -9,6 +9,11 @@ export default class SamplingWindow {
private document: Document | undefined
private visibility = () => this.clear()
begin(owner: Danmuku) {
if (this.time === undefined)
this.capture(owner, [], owner.art.currentTime)
}
capture(owner: Danmuku, rows: DanmuItem[], time: number) {
const doc = owner.$player.ownerDocument
if (doc !== this.document) {
@@ -105,7 +105,20 @@ export default class Scheduler {
schedule() {
const owner = this.owner
if (!this.running || this.closed || this.fault || owner.art.isDestroy || owner.isStop || this.frame !== null)
if (!this.running || this.closed || this.fault || owner.art.isDestroy || owner.isStop)
return
try {
// The public playing getter requires currentTime > 0; native play can start at zero.
const video = owner.art.video
const started = owner.art.playing || (video?.paused === false && !video.ended && video.readyState > 2)
if (started && !owner.isHide)
this.sampling.begin(owner)
}
catch (error) {
this.fail(error)
return
}
if (this.frame !== null)
return
this.frame = window.requestAnimationFrame(() => {
this.frame = null