Commit 15484bb6 authored by love_飞影's avatar love_飞影 Committed by Chunchi Che

refactor: 调整未启播逻辑

parent 7fcbe51f
......@@ -32,13 +32,15 @@ export class NeosAudioContext extends EventEmitter<AudioScheduledSourceNodeEvent
};
document.addEventListener("click", autoPlay);
}
// 如果超过音频长度还未播放,说明播放失败了,重新播放
// 50ms 未启播,说明播放失败了,重新尝试播放
const timeout = setTimeout(async () => {
if (source.loop) return;
if (this.state === "closed") return;
await this.suspend();
await this.resume();
}, buffer.duration * 1000);
if (source.context.currentTime === 0) {
await this.suspend();
await this.resume();
}
}, 50);
// 播放结束后关闭音频
const Ended = () => {
source.removeEventListener("ended", Ended);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment