For those looking to set up their own music streaming system on Linux, there are many options. Still, despite all of the attention going towards things like Emby, Plex, and Subsonic, a lot of Linux users still prefer a command-line based solution.Â That’s why in this article, we’ll be going over exactly how you can set up your own Linux-based music streaming tool with Music Player Daemon. We’ll go over how to stream over a network, how to set up individual MPD clients, and even how to use the terminal-based MPD tool with a traditional music player on Linux.
Install Music Player Daemon
Getting Music Player Daemon (MPD) working on Linux is a bit of a tedious process. It starts out by installing the client to whatever is hosting the stream. Know that you don’t have to use MPD over the network. It’s possible to install MPD and playback from it on the same PC.
sudo apt install mpd mpc
sudo apt-get install mpd mpc
sudo pacmanÂ -S mpd mpc
sudo dnf install mpd mpc
sudo zypper install mpd mpc
Can’t find MPD? Open up your terminal window and use the package manager to search for “MPD.” Install it, and you should be good to go. Be sure also to install the MPC tool, as that is also important. If your Linux distribution doesn’t support MPD at all, there are other ways to download it. The best way would be grabbing the source code itself, and building it.
To get a copy of the Music Player Daemon source code,Â head over to the official MPD website and grab the .tar.xzÂ version. This version will work on Linux.
Configuring Music Player Daemon
All edits to the Music Player Daemon tool must happen within the configuration file. Any changes to the system, while not required, will need to be made there. If you’d like to edit the file, open up a terminal window and enter the following:
sudo nanoÂ /etc/mpd.conf
By default, the MPD tool will store music files inÂ /var/lib/mpd/music, playlists inÂ /var/lib/mpd/playlists, and etc. MPD uses these locations for file storage because of permission purposes.Â The average user shouldn’t need to edit this file, as the regular locations are excellent.
‘); if (navigator.appVersion.indexOf(“Mac”)!=-1) document.write(‘
A better way to use MPD is just to use a bind mount. This kind of mount will automatically place the contents of ~/Music intoÂ /var/lib/mpd/music.
Note: if you’re hosting MPD on a server and not locally, consider just placing the files in /var/lib/mpd/music directly.
sudo mount --bind ~/Music /var/lib/mpd/music
Then, use the cat command to find the mount line in /proc/mounts.
cat /proc/mounts | grep ~/Music
Combining bothÂ catÂ and grepÂ will show us the exact mount line that ~/Music and /var/lib/mpd/music are bound. Now, to make this bind permanent. Be sure to change “/home/username/” to your PC’s user.
su echo '' >> /etc/fstab echo '# MPD Bind Mount' >> /etc/fstab echo '/home/username/MusicÂ /var/lib/mpd/music none rw,bind 0 0' >> /etc/fstab
Lastly, you’ll need to use the systemd init system to start the service.
sudoÂ systemctl enable mpd sudo systemctl start mpd
Gnome Music Player Client
There are many graphical MPD clients to use on Linux, and they all have their use cases. That said, not all of these clients are easy to use. In this tutorial, we’ll be connecting to the stream with the Gnome Music Player Client. Here’s how to install it.
sudo apt installÂ gmpc
sudo apt-get installÂ gmpc
sudo pacman -SÂ gmpc
sudo dnf installÂ gmpc
sudo zypper installÂ gmpc
Open GMPC to be taken through the “first launch” tool. It’ll help you set up a connection. If you’re using MPD from a remote Linux server, be sure to change “localhost” to it’s IP address. Not sure what the IP address is? Try this.
Find Public IP
ping pcdomainname.com -c1
OUTPUT:Â Â PING google.com (22.214.171.124) 56(84) bytes of data.
FindÂ Local IP
ping pc-host-name -c1
OUTPUT:Â PING ubuntu-server (192.168.1.126) 56(84) bytes of data.
Enter all the connection details and then move down to “music directory.” In this area, write the location /var/lib/mpd/music/. Don’t worry about entering a password, just click the connect button. If the connection is successful, click the “forward” button to move on to the next page.
As GMPC starts, you’ll notice that there aren’t any music files. No, this doesn’t mean that you set up the MPD server wrong and that you’ve got to start over. Gnome Music Player Client just has to build a database. Rebuilding the MPD database is a little like pressing the “scan library” button on your favorite local music player.
Refresh the database by clicking “Server,” then selecting “Update MPD Database”. You’ll then be able to play back any music in the /var/lib/mpd/music folder remotely, via GMPC. This app doesn’t update the database automatically. Each time new music files are added, you’ll need to refresh the client again.