That used to happen to me all the time, but it's feels like it's gotten better in 13.
Usually if I want to make sure a video stays active I'll put it in PiP mode. You can throw it off to the side, but then it's easy to pull back up and start if something interrupts it. Not ideal, but not a huge inconvenience either.
The whole Page Visibility API was a mistake to me. Under no circumstance I can think of I want a website to know if I am looking at it or not. In this case, I consider it to be plainly abused and turned user-hostile.
[0] https://addons.mozilla.org/en-US/firefox/addon/video-backgro...
TLDR: corporate greed
If someone made something that'd let me play YouTube in the background, I'd jump on it! Was thinking of using Pythonista and youtube-dl, but that got sidetracked.