'You may only play audio if such and such conditions are met. However these are different based on browser and platform. Good luck making a solution fitting all these.'
'The browser might lie about what's the available screen estate is, but only sometimes'
'There is a perfect API for what you wanna do, however it's not in Safari'
And a testament on how obscure and arcane knowledge is on doing things right is that I thought there would be some npm packages that do these things for me, but no - you have to hunt around for solutions and fix things yourself.
And LLMs are completely useless and confidently wrong mostly about everything involving this.