最近开发录音相关功能
发现有些录音当取audio.duration时为infinity,影响自定义功能的实现,查阅了很多方法都不起作用,最后在国外论坛找到了可行的解决方案。
private async audioCanplay(e: any) {
const firsthandAudio: HTMLAudioElement = e.target;
while (firsthandAudio.duration === Infinity) {
await new Promise(r => setTimeout(r, 200));
firsthandAudio.currentTime = 10000000 * Math.random();
}
this.duration = firsthandAudio.duration;
}