Screencasting sound goes on phone when screen's off

When I’m using screencast on my Xiaomi Mi 9T and I’m putting music on my phone, when my phone screen turns off, the sound goes on the phone and not on the screen anymore.

I tried on a OnePlus Nord and I have the same result.

How to avoid this behavior ?

I tried to find the cast on battery optimization list, maybe it could help, but I couldn’t find it. I already de-optimized battery for the app that I use to listen music.

Thanks all. Long live to /e/ !

Regain your privacy! Adopt /e/OS the deGoogled mobile OS and online servicesphone