задача, Нужно узнать когда возможно проиграть аудио
когда .catch все срабатывает
когда .then ничего не выводит. в .finally не заходит и console.log('end') не выводит
когда в .then делал clearTimeout тоже ничего не выводило, хотя setInterval прерывало
<body>
</body>
<script>let audio= document.createElement('audio')
let timerId = setTimeout(async function tick() {
console.log('begin')
let a=-1
await audio.play()
.then((e)=>{
console.log('ok')
a=0
})
.catch((error) => {
timerId = setTimeout(tick, 2500)
console.log(`play failed because the user didn't interact with the document first`)
a=1
})
.finally(()=>console.log(a))
console.log('end')
}, 2500);</script>