BTW if you browse YouTube with Firefox browser on Android you can play back YouTube videos with the screen locked using background player fix extension.
YouTube deliberately tries to prevent background playback by using web APIs to detect when the page is no longer visible and pausing the video. The extension prevents YouTube from doing that.