To play an MP3 file, navigate to the location of the .mp3 file in the terminal using
cdand then type the following command:
This will play the audio file
example.mp3through either your monitor’s built-in speakers or your headphones, connected via the headphone jack.
If you need an example file you can download one from here using the following command:
wget https://goo.gl/XJuOUW -O example.mp3 --no-check-certificate
If you cannot hear anything, make sure your headphones or speakers are connected correctly. Note that omxplayer doesn’t use ALSA and so ignores the audio configuration set by
If omxplayer’s auto-detection of the correct audio output device fails, you can force output over HDMI with:
omxplayer -o hdmi example.mp3
Alternatively, you can force output over the headphone jack with:
omxplayer -o local example.mp3
You can even force output over both the headphone jack and HDMI with:
omxplayer -o both example.mp3
CHANGING THE AUDIO OUTPUT
There are two ways of setting the audio output.
The following command, entered in the command line, will switch the audio output to HDMI:
amixer cset numid=3 2
Here the output is being set to
2, which is HDMI. Setting the output to
1switches to analogue (headphone jack). The default setting is
0which is automatic.
Open up raspi-config by entering the following into the command line:
This will open the configuration screen:
Select Option 8
Advanced Optionsand press
Enter, then select Option A6:
Now you are presented with the two modes explained above as an alternative to the default
Autooption. Select a mode, press
Enterand press the right arrow key to exit the options list, then select
Finishto exit the configuration tool.
IF YOU’RE STILL NOT GETTING SOUND VIA HDMI
In some rare cases, it is necessary to edit
config.txtto force HDMI mode (as opposed to DVI mode, which does not send sound). You can do this by editing
hdmi_drive=2, then rebooting for the change to take effect.