FYI there is a firefox addon to block the visibility API I can now listen to the UK PM's coronavirus update on my phone with the screen locked, or while looking up something else.
Whoever invented that API forgot whose client the browser is. Mine.
Then you are doomed. ;-) (On mobile, it's your browser anyway that mutes any not currently on top and visible web sources, without any "help" by the particular website.)
I know this is an old topic now, but that's not true. I've installed a firefox plugin that disables the visibility API. Result - now youtube in a firefox tab keeps playing even with my screen locked.