I bet that you once in your life was thinking about hearing songs on YouTube when you lock your screen or switch to another app. Pretty dream but it doesn't have to be impossible to do. It's very simple on Android. All you have to do is download app called "YouTube Vanced". It looks like ordinary YouTube app but have extra options. Did you hear that iPhone users can change main color of YouTube to black. It's very helpful when you want to watch YouTube at night.
Of course you can listen your favorite songs when your screen is turned off.
For more information about this app I recommend you to go to xda site
https://forum.xda-developers.com/android/apps-games/app-youtube-vanced-edition-t3758757
Here is explained how to install this application and more.
That's all I want to say in my first post.
(English is not my native language so if I made a mistakes please write in comment below)