Is there a way to keep youtube videos etc playing even while closing the lid? This worked before I reinstalled android with some app that I don't remember which. A common situation is that I start a youtube video, start listening and then put the phone in my pocket. And then the sound stops after closing the phone. I'd like youtube and other selected programs to keep playing. Is there a way to achieve it? I believe there was a program that could do it where a whitelisted youtube etc to keep playing in the background or similar.
For YouTube you would need to subscribe to YouTube Music Key. This allows you to 


  play music on mobile the way you want to – with or without video, while using other apps or with your screen off.


It also removes adverts from music videos and allows you to download &amp; play videos offline.

I'm not aware of how to achieve this with other apps (which don't support playing in the background).