Here’s a solution using entirely free and open source software. The basic idea is that although YouTube can’t play clips in the background, VLC for Android can play clips in the background, so all we need to do is pipe the clip to VLC where we can listen to it minimised.
That sounds complicated, but luckily there is software that does it for us.
- Install NewPipe (either from APK or from the Fossdroid app).
- Install VLC Android.
- Open NewPipe, and in Settings, make sure that Use External Player has a checkmark.
- Open VLC, and in Preferences, make sure that Play videos in background has a checkmark.
- Now, when you play a video in NewPipe, on the dialog that appears select VLC player. It will play in VLC and you can do other things while it plays.
- Download MX Player
- Play YouTube video using MX Player.
- Press Menu button (or the 3 dot icon), and then select Play
- Make sure “Background Play” is checked
- Now, you can press Home Button and listen in lock screen.
There is also a shortcut for enabling Background Play, which is tapping and holding the Play button, instead of just tapping it to play a video
Now MX player is not allowing to play youtube videos directly as mentioned by narayanan.
- You need to download UC browser .
- Now play the youtube video through UC browser
(The other browsers redirect to youtube app but it wont since it has its own built in player)
- Now you have to select option called Play With in top of video player and select MX player.
Only For Rooted: You can install Xposed Modules Installer and use Repository called Youtube Background Play
Try YouTube Vanced
For non-rooted phone:
- Install the MicroG APK if you want to log in with your YouTube
- Find the YouTube Vanced APK that you want and download it.
- Install the APK like you normally would.
For rooted phone:
- Download the official installer found in downloads above
- Select a suitable apk for your device (check your architecture using an app such as CPU-Z) and the secondary theme you want to. (All apks include the white theme)
- Place the downloaded apk into /sdcard/Downloads or inside the installation zip
- Uninstall all YouTube updates and disable auto-update in the playstore (If you are able to completely uninstall the youtube app do so)
- Flash the installer in TWRP
TubeMate YouTube Downloader is a great app that will let you download either the audio or the video from a YouTube file and save it to your device. When it is on your device, you are then able to use a media player (such as DoubleTwist) to play either in the background. But as for straight background music from YouTube, that’s a no-go :/