2. Open Firefox and go to this link - video playback fix or search for it by going to Tools > Add-ons > Browser All Firefox Addons. Once there, tap on the toggle switch to enable the add-on.
3. And that's it. Play any YouTube on Firefox (no need to turn on the desktop mode), and now if you close the app, switch to other app or even lock your screen; the video will still play in the background.
You can even pause playback or switch tracks in a playlist, from the notification tray.
Firefox stream both Audio and video when it runs in the background. But if you only want to stream Audio, try NewPipe. The app is open source and only available on Fdroid for obvious reasons.
Related: How to Listen to YouTube with Screen OFF (Android & iOS)
Or check out this quick video
https://www.youtube.com/watch?v=duNWxpbAvPQ&t=0s
Updated: October 10, 2021