docs: add comment explaining waitReady logic
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user