My cats love to watch videos with insects, mice, etc. The problem is they touch the screen and sometimes close YouTube.
Is there a way to keep playing the video but lock the screen?
You can use your preferred media player that has a lock function (personally, I use MX Player Pro) in combination with the App Pinning feature, which (on my Android 11 device) is found under Settings > Security & Lock Screen
here:
The lock function should prevent all app UI touches while app pinning should prevent notification as well as navigation bar touches.
The only caveat would be the random chance of them touching the unlock button, but for MX Player specifically there is a setting you can enable called "Kids Lock", which disables the unlock key while implementing a 4-touch (corners, starting from top left, in clockwise order) unlock procedure with no visible queues.
Of course, bear in mind that there's still the significantly less likely scenario of even this being activated by pure random chance. If you're the type that doesn't want to leave anything to chance, you may want to look at, e.g., this type of solution, or look at applications like Touch Blocker.