Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, the browser checks the call stack of the javascript function. If the play() isn't a direct result of some kind of user interaction. It will just deny you from playing audio.

So play upon you open the page is no longer possible. You at least need to wait for the user to touch somewhere on the page.



Yeah there's all sorts of nonsense you can do to do autoplay. I kind of remember at one of my old jobs, to get autoplay working on some elearning courses, when the user clicked 'Start', we'd start the audio but not play anything, and then switch out the file that was played when required which would 'autoplay' as the user had already initiated the sound. At least that was the general idea afaik.


Only works well on single-page applications. A much more insidious strategy is to bind to the "Accept cookies" button.


and now all we need to do is the same for video...


Video does the same thing, except you can autoplay it if it's muted.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: