YouTube app for iOS and Android devices doesn't allow you to play videos in the background. Usually, you would like to have this option to listen to music or play audio on the go. There are a few ways to play YouTube in background on jailbroken and no-jailbroken devices.
YouTube on iOS
To allow youtube background play on iOS devices you can consider to install Opera Touch for iPhone. The browser can play in background videos from YouTube. It's not a perfect solution but it works.
Play YouTube in background iOS
The better way to watch videos in the background is to install an app from unofficial App Store. It doesn't require a jailbreak to work. Try YouTube++ that offers an option for youtube background play. Moreover, you can download videos. There is also YouTube Download app offering the same features.
Step 1. Install Tutuapp, the AppStore alternative.
Step 2. Open the app and search for YouTube++ or YouTube Download.
Step 3. Click Download → Install.
Step 4. You should see the app icon on your home screen.
Step 5. Navigate to Settings → General → Device Management.
Step 6. Click on the Enterprise Apps the publisher name and trust the certificate.
For jailbroken iOS devices there are few apps and tweaks available in Cydia repository. A great solution is a tweak called YouTubed. When installed it allows you to play YouTube in background on iOS. Use the official YouTube app for playback. The controls will be available form the lock screen.
How to install YouTubed
You are just a few steps from installing the tweak from Cydia Sources. To add YouTubed Repository to your list of Cydia Sources follow our step-by-step guide.
Step 1. Launch the Cydia application.
Step 2. Tap Sources → Edit → Add the official BigBoss repo.
Step 3. Switch to Search Tab and enter YouTubed.
Step 4. Tap the Install button.
Step 5. To activate the app go to Settings → YouTubed.
YouTube on Android
The YouTube Android app available in Google Play also doesn't offer an option to play video when the phone is locked. You can play the video using Google Chrome and notification menu. Tutuapp is also available for Android, and you can access from there dedicated apps for your mobile device.
Step 1. Open Chrome browser and navigate to www.youtube.com.
Step 2. In the three-dot menu at the top right, check the "Request desktop site" box.
Step 3. Open the video and click play.
Step 4. When YouTube wants to send you notifications, accept it.
Step 5. Resume playback from the notification menu.