How to play YouTube videos in the background on Android devices

Default featured post

How to play YouTube videos in the background on Android devices. YouTube recently starts offering YouTube Premium (previously known as YouTub Red) with features to [play background videos without any advertisement and ability to download videos. YouTube Premium costs $11.99 per month which is not very cheap.

If you are like me and don’t want to pay for anything, yet be able to enjoy playing videos, mainly music, in your Android devices keep on reading.

There are two free options which you can use to play YouTube videos in the background on your Android devices which are as follows:
– Firefox + Video Background Play Fix plugin
– Termux + mpv + mps-youtube

Firefox + Video Background Play Fix plugin

The process is fairly simple. Just download Firefox browser from your store and install it on your device. After that go to the Add-ons page and search for Video Background Play Fix. Install the plugin, restart your Firefox and then enjoy playing YouTube videos in the background for free. If you wish to skip advertisements as well, you need to install another add-on called Adblock Plus.

Termux + mpv + mps-youtube

If you are a more adventures person who wants to play a little bit with the Linux command line and enjoy working in a text-based environment, this option suits you well. This can be achieved in three steps which are:

  • Termux installation
  • Mpv installation
  • Mps-youtube installation

Termux Installation

First, you need to download and install Termux on your Android device.
Termux is a very powerful and capable Terminal emulator which comes with a very software repository. The only downside is Termux only runs on devices equipped with Android version 5.0 or above.
After installing Termux, fire it up and run apt update and upgrade:

$ apt update
$ apt upgrade

Mpv Installation

The second step is to install a player. My recommendation is mpv. To install it type in your Termux window:

$ apt install mpv

Mps-youtube Installation

After done installing mpv, need to install python and pip. These two packages are necessary in order to install mpsyt. To do we can use pkg command instead of apt which is a package manager provided by Termux:

$ pkg install python

The above command installs python 3 as well as pip in one shot.
The last step is to install mps-youtube which also known as mpsyt. Mpsyt essentially is a terminal based YouTube application with many useful features include downloading vidoes. To install mpsyt run the following command:

$ pip3 install --user mps-youtube

Mpsyt doc highly recommends the installation of youtube-dl which allows you to download YouTube as well. To install youtube-dl run this command in Termux:

$ pip3 install --user youtube-dl

Now you should be able to type mpsyt in your Termux window. Before searching for any videos, need to do a simple configuration. While your mpsyt is running type h config. Then type set player mpv and enter.

Mpsyt commands

Everything is ready to work now. You can start searching for anything using /[query string] and play the video just type the associated number next to the search result. To bulk play either give numbers you would like to play in a comma separated format (1, 5, 10) or in sequence such as 1-10.
If you wish to go to the next page of the search result, just press n and enter. To go back, press p.
To download a video just type d [number] then select a format you wish to download.
To download audio of a video, type da [number].

Advantages

  • No advertisements

Disadvantages

  • Inability to display video without downloading it