docs: add comment explaining waitReady logic

This commit is contained in:
2026-06-07 17:05:59 +08:00
parent 937e45c203
commit b96a12a2f3

View File

@@ -141,7 +141,9 @@ export class VideoManager {
}
private waitReady(el: HTMLVideoElement): Promise<void> {
// readyState >= 2 (HAVE_CURRENT_DATA) 表示已有足够数据播放当前帧,无需等待
if (el.readyState >= 2) return Promise.resolve()
// 否则等待 canplay 事件(浏览器判断可开始播放),同时手动触发 load 确保加载流程已启动
return new Promise((resolve) => {
el.addEventListener('canplay', () => resolve(), { once: true })
el.load()