Raspberry Pi Music Player
We all know that Raspberry Pi is a multipurpose System on-chip computer which is capable of doing all the functionalities of a general purpose computer with a low bandwidth. Everyone wants to have a customised audio player at home. Raspberry Pi is capable of providing a standard quality audio through its 3.5 mm audio jack. If you want to have a high quality audio output from Raspberry Pi, there are USB plug and play add-on hardware plugins are available, you can make use of it. For the audio player we are going to build using Raspberry Pi, standard output holds good.
In this tutorial we will show you how to build a simple music player which can be controlled using your mobile phone remotely. You can connect your Raspberry Pi nor only to any audio system which supports 3.5 mm audio input jack but also to a Bluetooth speaker. Hope your Raspberry Pi is already configured and running fine. If not, you can refer our previous tutorial on Raspberry Pi server.
Raspberry Pi Audio Player – Components
|Raspberry Pi||Raspberry Pi 3 (recommended)|
|Memory Stick||8GB (minimum)|
|Card Reader||Any to read/write memory stick|
|Power Supply||5V -1A (micro usb)|
|Speaker||Any audio system with 3.5 mm Jack|
|Pen drive||In case of dedicated music player|
You should configure your Raspberry Pi audio output, either it has to come from audio jack output or HDMI output. You can configure it by opening raspi-config (sudo raspi-config). Later if you use our Raspberry Pi to connect to a HDMI enabled Tv for that you need HDMI audio output.
So enable auto since it will automatically switch between audio jack and HDMI based on your connection.
For controlling your music player remotely, you need to install two applications in your mobile. We are going to build our music player in two contexts.
- Having a dedicated music player built on Raspberry Pi
- Music player which will broadcast songs from your mobile phone.
For the first one you need to install Remote Desktop Controller for android. Through that we can browse the files in our Raspberry Pi and play those files on our Raspberry Pi remotely. You can use this app for other purpose also wherever RDC is required. The touch control app for this app is pretty impressive.
The latter one is used to cast your music files from your mobile phone to the Raspberry Pi and playing it on the speaker which is connected to Raspberry Pi. This is for the users who doesn’t want to fill the Raspberry Pi’s memory which probably they may need for their project later. Through this you can cast images and video files. This helps you to create an instant playlist of 50 songs.
Now we are going to install music players on Raspberry Pi through that we are going to play the .mp3 files. Like windows or any other operating system, its not that easy to download packages directly and install them. So we will be using command line interface to install the audio player. Install any player of your need.
To install VLC:-
sudo apt-get install vlc -y
To install Rhythm Box:-
sudo apt-get install rhythmbox -y
To install Synaptic:-
sudo apt-get install synaptic -y
After installing these players you can able to see them in the start menu under sound and video as shown below.
You can connect your speaker to the Raspberry Pi directly via the 3.5mm audio jack. For testing you can now use your earphones.
For connecting your Bluetooth speaker, you can’t simply connect alike in you windows or mac. Some internal configurations are to be made as follows.
First install the Raspberry Pi ‘s Bluetooth firmware by these commands.
sudo apt-get install pi-bluetooth
After installing Bluetooth, support software for Bluetooth is installed using the command below.
sudo apt-get install blueman pulseaudio pavucontrol pulseaudio-module-bluetooth
Now open Start Menu > Preferences > Bluetooth Manager to open Bluetooth manager and start searching and connect to your preferred Bluetooth audio device.
Open Pulse audio to control volume of your Bluetooth speaker.
Now login to your Raspberry Pi using your RDC in your mobile phone. For that you need the IP address of your Pi. If you don’t know how to find the IP address refer our last tutorial on Raspberry Pi as a Server . Fill in the credentials in RDC and login.
Note: Your mobile and Raspberry Pi has to be connected in the same local network. After logging in using RDC, you can access the GUI of Raspberry Pi OS. You can use your touchscreen as a mouse-pad to browse the GUI screen of Raspberry Pi , double tap will serve as double click and a two finger touch will serve as right click.
If you got more space in your memory card, like you have installed your Raspberry Pi OS in a memory card of size 16 Gb or more you can create a folder dedicated to your songs and play them using any music player app installed in your Raspberry Pi. If you have very less space then you can plugin your song filled pen drive and browse your songs and play them. Depending on your music player, you can directly open the player and start playing your playlist if you have created before. I recommend you to use Rhythm box, as it is specially designed for the Linux based operating system.
This application is for those who don’t want to use Raspberry Pi’s memory since they might be using that space for their college project or some other thing, but want their songs to be played in a dedicated player. You will be playing songs from your mobile but in a most power efficient way by forecasting your songs via SSH to Raspberry Pi.
Now open your Raspicast App in your mobile and open SSH settings from side menu .
Fill in the hostname/IP address and other credentials then click ‘ok’.
Now Go to the CAST menu from the main screen and slide right to Music and press the song to cast it to the Raspberry Pi.
Raspicast allows you to create a playlist of around 50 songs instantly by long pressing the next song you want to play and queue it up as shown below.